如何旋转.transitionCurlDown动画以获取书页的旋转(水平而非垂直),与此相同:
有垂直页面卷曲动画:
UIView.transition(with: self.myView, duration: 0.7,
options: .transitionCurlDown, animations: {
})
重要:我不想在UIViewControllers或UIPageControllers之间使用过渡,我想在当前屏幕上的UIView上应用动画。
答案 0 :(得分:1)
只需一个音符就可以接受答案。如果您想像翻书动画那样使用它,请将imageView.image
从封面更改为页面,例如,在此行animatePage(side: .left, textView: myTextView)
因此,如果您有cover
张图片和page
张图片,则您的代码应类似于:
imageView.image = UIImage(named: "page.png")
animatePage(side: .right, view: imageView)
这将为您提供从封面到页面的漂亮翻页动画
答案 1 :(得分:0)
解决方案:
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)