简体   繁体   中英

page curl transition like a book two sides (transition from right side to left side & vice versa)

Hy, i want to make a pagecurltransition like in a book, when i press one button is curlup and i want to see while the transition is beeing made the next page. And for curldown i want the transition view to be with the next page. Like when i move pages in a book. The transition works fine but the problem is that i want my instruction to be executed while the transition is beeing done. The problem is that mywebview loads the text after the transition is done.

UIViewAnimationOptions animation;
if (_webview) {
    animation = UIViewAnimationOptionTransitionCurlDown;
} else {
    animation = UIViewAnimationOptionTransitionCurlUp;
}
CATransition *aanimation = [CATransition animation];
[aanimation setDelegate:self];
[aanimation setDuration:1.0f];
aanimation.startProgress = 0.5;
aanimation.endProgress   = 1;

[aanimation setSubtype:kCATransitionMoveIn];

[aanimation setRemovedOnCompletion:NO];
[aanimation setFillMode: @"extended"];
[aanimation setRemovedOnCompletion: NO];
[[_webview layer] addAnimation:aanimation forKey:@"WebPageCurl"];

UIWebView is tricky because it doesn't render immediately, so it isn't ready when you take the snapshot for your page animation. The best you can hope for is like Flipboard, where you flip the page and it fades in. Otherwise you have 2 choices.

1) Keep a cache of your next and previous page around always (this is what I did when I was trying to get around this problem)

2) Wait for the web views to load before playing the animation (this will cause a noticeable delay and is not advisable)

只需添加UIViewAnimationOptions.AllowAnimatedContent作为额外的参数,即可在其中提供curlup / curlDown动画。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM