ios - 如何旋转.transitionCurlDown动画?

标签 ios swift animation

如何旋转.transitionCurlDown动画来获取书页的旋转(水平,而不是垂直),与此相同:

enter image description here

有垂直翻页动画:

UIView.transition(with: self.myView, duration: 0.7, 
options: .transitionCurlDown, animations: {
})

重要提示:我不想在 UIViewController 或 UIPageController 之间使用过渡,我想在当前屏幕上的 UIView 上应用动画。

最佳答案

解决方案:

func animatePage(side: PageCurl, textView: UITextView) {
    UIView.animate(withDuration: 0.3, animations: {
        let animation = CATransition()
        animation.duration = 0.3
        animation.startProgress = 0.0
        animation.endProgress = 1
        animation.timingFunction = CAMediaTimingFunction(name: CAMediaTimingFunctionName.easeInEaseOut)
        animation.type = CATransitionType(rawValue: "pageCurl")
        if side == .left {
            animation.subtype = CATransitionSubtype(rawValue: "fromLeft")
        } else {
            animation.subtype = CATransitionSubtype(rawValue: "fromRight")
        }
        animation.isRemovedOnCompletion = false
        animation.isRemovedOnCompletion = false
        textView.layer.add(animation, forKey: "pageFlipAnimation")
    })
}

用途:

animatePage(side: .left, textView: myTextView)

关于ios - 如何旋转.transitionCurlDown动画?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52866956/

相关文章:

JSON 字符 0 周围值无效调试

c# - 为什么在 Storyboard设置动画时属性上的设置函数不更新

ios - UIButton 的返回动画不起作用

ios - 无法在 Firebase 身份验证中链接 Facebook 和 Google

ios - 大多数视频没有从 YouTube 获得 VideoUrl

ios - CLLocationManager 问题

ios - 如何以编程方式将搜索栏放在导航栏中? - swift

Swift 计时器检查 TouchesEnded

iphone - UITableViewCell 内旋转的 UITableView 未显示 initWithFrame : says to

javascript - 使用 easeljs pan 的 HTML5 Canvas