【问题标题】:Partial pagecurl animation with swiftswift的部分pagecurl动画
【发布时间】:2017-01-29 17:19:39
【问题描述】:

我正在寻找一种在 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

【问题讨论】:

    标签: ios swift xcode uiview page-curl


    【解决方案1】:

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

    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)
        })
    

    【讨论】:

    • @Leena 我已经调用了 viewdidload 因为我在同一页面上加载另一个数据,您可以根据您的选择进行修改
    【解决方案2】:
    UIView.animate(withDuration: 1.0, animations: {
        let animation = CATransition()
        animation.duration = 1.2
        animation.startProgress = 0.0
        animation.endProgress = 0.6
        animation.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseOut)
        animation.type = "pageCurl"
        animation.subtype = "fromRight"
        animation.isRemovedOnCompletion = false
        animation.fillMode = "extended"
        self.animatedUIView.layer.add(animation, forKey: "pageFlipAnimation")
        self.animatedUIView.addSubview(tempUIView)
    })
    

    【讨论】:

      【解决方案3】:

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

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

      【讨论】:

      • 我已经这样做了。现在我想在第一页上放一个预告片,向用户展示还有更多页面要来,他可以滚动浏览。就像右下角的一个小边缘有点卷曲。
      • 我听到了。我在项目中实现这一点的方式是使用带有 curl 图像背景的 UIButton,当用户按下该按钮时,它将触发 curl 动画。
      猜你喜欢
      • 2019-11-26
      • 1970-01-01
      • 2015-05-01
      • 2010-12-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-11-24
      相关资源
      最近更新 更多