部分pagecurl动画与swift

时间:2016-09-21 12:42:03

标签: ios swift xcode uiview page-curl

我正在寻找一种在uiview上指示pagecurl动画的方法,以便向用户提供他可以滚动浏览某些页面的提示。它应该是某种部分页面卷曲。

问题是我不知道该怎么做。我找到了一些教程,但仅针对目标c,我不知道如何将其转换为swift:

 [UIView animateWithDuration:1.0
                     animations:^{
                         CATransition  * animation = [CATransition animation];
                         [animation setDuration:1.2f];
                         animation.startProgress = 0.0;
                         animation.endProgress   = 0.6;
                         [animation setTimingFunction:UIViewAnimationCurveEaseInOut];
                         [animation setType:@"pageCurl"];
                         [animation setSubtype:@"fromRight"];
                         [animation setRemovedOnCompletion:NO];
                         [animation setFillMode: @"extended"];
                         [animation setRemovedOnCompletion: NO];
                         [[self.animatedUIView layer] addAnimation:animation
                                                      forKey:@"pageFlipAnimation"];
                          [self.animatedUIView addSubview:tempUIView];

                     }
     ];

http://www.iostute.com/2015/04/how-to-implement-partial-and-full-page.html

3 个答案:

答案 0 :(得分:6)

post = models.ForeignKey(Post)

答案 1 :(得分:0)

我认为你可以使用UIPageViewController。 我为我的项目做了类似的事情。本教程很有帮助。

https://spin.atomicobject.com/2015/12/23/swift-uipageviewcontroller-tutorial/

答案 2 :(得分:0)

为帮助您,我将相同的代码更新为最新版本

UIView.animate(withDuration: 1.0, animations: {
        let animation = CATransition()
        animation.duration = 1.2
        animation.startProgress = 0.0
        animation.endProgress = 0.6
        animation.type = CATransitionType(rawValue: "pageCurl")
        animation.subtype = CATransitionSubtype(rawValue: "fromRight")
        animation.isRemovedOnCompletion = false
        animation.fillMode = CAMediaTimingFillMode(rawValue: "extended")
        animation.isRemovedOnCompletion = false
        if let animation = animation as? CATransition{
            self.view.layer.add(animation, forKey: "pageFlipAnimation")
            self.viewDidLoad()
        }
        self.view.addSubview(self.TableView)
    })