How can I give Page flip effect in `UIScrollview`?

前端 未结 1 1868
我寻月下人不归
我寻月下人不归 2021-02-06 18:22

I am working on an application in which I am using UIScrollview, in that I need to use page flip effect.

How can I give Page flip effect in UIScrollvi

相关标签:
1条回答
  • 2021-02-06 18:56

    Forward flip -

    CATransition *animation = [CATransition animation];
    [animation setDelegate:self];
    [animation setDuration:1.0f];
    animation.startProgress = 0;
    animation.endProgress   = 1;
    [animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
    animation.type = @"pageCurl";
    animation.subtype=@"fromRight";
    animation.fillMode = kCAFillModeForwards;
    
    [animation setRemovedOnCompletion:NO];
    [animation setFillMode: @"extended"];
    [animation setRemovedOnCompletion: NO];
    [lyr addAnimation:animation forKey:@"WebPageCurl"];
    

    Backward flip -

    CATransition *animation = [CATransition animation];
    [animation setDelegate:self];
    [animation setDuration:1.5f];
    animation.startProgress = 0;
    animation.endProgress   = 1;
    [animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
    animation.type = @"pageUnCurl";
    animation.subtype=@"fromRight";
    animation.fillMode = kCAFillModeBackwards;
    
    [animation setRemovedOnCompletion:NO];
    [animation setFillMode: @"extended"];
    [animation setRemovedOnCompletion: NO];
    [lyr addAnimation:animation forKey:@"WebPageCurl"]; 
    

    you can use this code when UIScrollView delegates.

    0 讨论(0)
提交回复
热议问题