How to do "pushviewcontroller" animation WITHOUT using pushviewcontroller?
I want to do animation like NavigationController pushviewcontroller's animation. but I don't have a NavigationController, I don't want to make it.
So I want to ask is it possible to do it's animation in UIViewController? thanks!
开发者_运维知识库
oh forgot to say, I'm trying to switch view after clicking button. Using presentModalViewController now, but I don't like it's animation..
You could animate the origin
property of your sub view, make it decreasing along the x axis just after adding it to the main view.
EDIT :
Use something like this :
// retrieve the screen bounds
CGRect sBounds = [[UIScreen mainScreen] bounds];
// the origin point is just on the right of the screen
CGRect newFrame = CGRectMake(sBounds.size.width,
0.0,
sBounds.size.width,
sBounds.size.height);
// set your view frame
[mySecondView setFrame:newFrame];
// add it to the main view
[mainView addSubview:mySecondView];
// then animate your view
[UIView animateWithDuration:0.5 // set the interval you want
animations:^{
mySecondView.frame.origin = sBounds.origin;
}
];
I would use a navigation controller and hide the navigation bar, but as you don't want to do that you can switch between views using [UIView beginAnimantion: @"myAnimation" withContext: nil];
and changing the frame or the origin.
精彩评论