How to make half curl animation in iPhone like the

2019-01-14 05:31发布

问题:

I am using the following code for page curl animation

[UIView beginAnimations:@"yourAnim" context:nil];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:yourView cache:cacheFlag];
...
[UIView commitAnimations];

Is it possible to make the half curl animation like the maps.app on iphone/ipod ?

Any ideas how to make an similar effect ?

Thanks

回答1:

Apple does support this for the presentation of modal views as of 3.2. This makes sense: the page curl effect is intended to signal the user that a page of options or settings is being revealed, and when they are done changing things, they will be sent back to the original view. Apple doesn't want the animation to infer an ongoing change to the page hierarchy, just a modal one that must return to its starting place.

It's pretty straightforward to use; just be sure that you are starting from a full screen view, and loading with the UIModalPresentationFullScreen style, which I believe is the default.

There are animation transitions to use a similar effect in UIViews generally that were added as of 4.0, but this is a straightforward way to use the effect.

simpleVC * myModalVC = [[simpleVC alloc] init];
[myModalVC setModalTransitionStyle:UIModalTransitionStylePartialCurl];
[myModalVC setDelegate:self];

[self presentModalViewController:myModalVC animated:YES];
[simpleVC release];

Link to Apple Docs on UIModalTransitionStyle constants



回答2:

I too have been working on this issue and I settled in the short term on a PNG version of it placed within a button and using the curl to reveal animation. The only thing missing in my solution is the ability to interact (play) with the curling page the way you can in Maps.

The Method

First, I created a Page corner PNG in Photoshop based on a screenshot of Maps.

The Map Curl PNG

The Map - Options Hidden

The Map - Options Revealed

Then, I added it to a UIButton that does a partial page curl transition.

Complete Source Code Available on GitHub

The complete working project is available at GitHub. Updated for iPhone 5.



回答3:

Use the undocumented animation types mapCurl and mapUnCurl