page curl effect to transit between classes in iphone
i am working with page curling effect .on click of a button i was able to transit the page(i.e between the UIViews).the following code depicts the same
UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1.5];
if ([sender tag] == 1) {
[UIView setAnimationTransition:UIViewAnimationTransitionCurlDown forView:placeholder cache:YES];
}
else {
[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:placeholder cache:YES];
}
if (view1OnTop) {
[view1 removeFromSuperview];
[placeholder addSubview:view2];
}
else {
[view2 removeFromSuperview];
[placeholder addSubview:view1];
}
[UIView commitAnimations];
view1OnTop = !view1OnTop;
with this i was able to curl between UIViews ,but my question is , will i be able to apply this kind of transition be开发者_C百科tween two or more classes??? thanks in advance
Not everything is animatable. Only parts of UIKit are. So if you mean to ask if any subclass of NSObject
can be animated then no they can't. If you mean to ask if whether subclasses of UIView
can be animated then the answer would be yes. They can be different subclasses too. While this is possible, it doesn't mean it will give us the right results. They might end up looking pretty weird. You might not want to do that.
Layers are animatable too.
However it all depends on what you mean by classes.
Animating to a new view controller
Say you want to alter the way you shift between view controllers, you can use transitionWithView:duration:..
class method of UIView
. An example,
SecondViewController * viewController = [[[SecondViewController alloc] initWithNibName:nil bundle:nil] autorelease];
[UIView transitionWithView:self.view.window
duration:1.0f
options:UIViewAnimationOptionTransitionCurlUp
animations:^{
[self.navigationController pushViewController:viewController animated:NO];
}
completion:NULL];
This will use the curl up transition when pushing the new view controller.
For iOS versions older than 4.0
Since they don't support block based animation APIs, you will have to do this,
[UIView beginAnimations:@"Curl up" context:NULL];
[UIView setAnimationDuration:1.0f];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.view.window cache:YES];
[self.navigationController pushViewController:viewController animated:NO];
[UIView commitAnimations];
精彩评论