How to create a page curl animation?

2020-07-11 05:36发布

问题:

Any way to emulate something like this? Isn't there an API for doing something like a "Half page curl" or something?

回答1:

controller.modalTransitionStyle = UIModalTransitionStylePartialCurl;
[self presentModalViewController:controller animated:YES];

UIModalTransitionStyle Transition styles available when presenting view controllers modally. The below are the four different transition styles. The "UIModalTransitionStylePartialCurl" is the one you're after.

typedef enum {
    UIModalTransitionStyleCoverVertical,
    UIModalTransitionStyleFlipHorizontal,
    UIModalTransitionStyleCrossDissolve,
    UIModalTransitionStylePartialCurl,
} UIModalTransitionStyle;

Apple documentations: http://developer.apple.com/library/ios/#documentation/UIKit/Reference/UIViewController_Class/Reference/Reference.html

Hope this helps!



回答2:

Try the following. In this case Settings is a sublcass UIViewController to be presented behind the page curl. self is also a UIViewController that is being displayed an it's view will stay on top.

-(void)presentSettings{
    Settings *eset = [[Settings alloc] init];
    //eset.modalPresentationStyle = UIModalPresentationFullScreen;
    eset.modalTransitionStyle = UIModalTransitionStylePartialCurl;
    [self presentModalViewController:eset animated:YES];
}

Notice that the Curl is only available in iOS 3.2 and later.



回答3:

I think this may be what you're looking for:

[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1];
[UIView setAnimationBeginsFromCurrentState:YES];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.view cache:YES];
[UIView commitAnimations];