开发者

Partial page curl animation

I have a working transition using UIViewAnimationTransitionCurlUp however, I would like the animation to stop halfway through, much like the M开发者_JAVA技巧aps application...Any thoughts on how to achieve this?


In iOS 3.2 and later, you can give your UIViewController a UIModalTransitionStyle of UIModalTransitionStylePartialCurl. From the UIViewController reference, we see

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

So an example use case would be:

UIViewController *viewController;
// …create or retrieve your view controller…

// Note: The modalPresentationStyle must be UIModalPresentationFullScreen,
//       and the presenter must also be a full-screen view
viewController.modalPresentationStyle = UIModalPresentationFullScreen;
viewController.modalTransitionStyle = UIModalTransitionStylePartialCurl;


I found a solution to add an UIView to UIViewController using Animation block.

m_Container is an UIView who contain my view animation (self). self is an UIView.

CAUTION : You need to have import QuartzCore

To present view with page curl animation you can use :

-(void)PresentView
{
    [UIView animateWithDuration:1.0 
                     animations:^{
                         CATransition *animation = [CATransition animation];
                         [animation setDelegate:self];
                         [animation setDuration:0.7];
                         [animation setTimingFunction:UIViewAnimationCurveEaseInOut];
                         animation.type = @"pageCurl";
                         animation.fillMode = kCAFillModeForwards;
                         animation.endProgress = 0.65;
                         [animation setRemovedOnCompletion:NO];
                         [m_container.layer addAnimation:animation forKey:@"pageCurlAnimation"];  
                         [m_container addSubview:self];
                         ;}  
     ];    
}

And when you want hide this view you can use :

-(void)HideHelpView
{
    [UIView animateWithDuration:1.0 
                     animations:^{
                         CATransition *animation = [CATransition animation];
                         [animation setDelegate:self];
                         [animation setDuration:0.7];
                         [animation setTimingFunction:UIViewAnimationCurveEaseInOut];
                         animation.type = @"pageUnCurl";
                         animation.fillMode = kCAFillModeForwards;
                         animation.startProgress = 0.35;
                         [animation setRemovedOnCompletion:NO];
                         [m_container.layer addAnimation:animation forKey:@"pageUnCurlAnimation"];  
                         [self removeFromSuperview];

                         ;}  
     ];

}


The Maps partial curl is a private API. You can find details of how to use it in Erica Sadun's book The iPhone Developer's Cookbook, but you will get rejected from the App Store for using it.


Not sure if this will work, but the parameter to +setAnimationRepeatCount: can be a fraction.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜