[英]Swift 4 CATransition flipping UIView without 3D effect
I wanna flip an UIView in a ViewController without the 3D effect, is it possible to do that? 我想在没有3D效果的情况下在ViewController中翻转UIView,可以这样做吗?
let transition = CATransition()
transition.duration = 0.5
transition.type = "flip"
transition.subtype = kCATransitionFromLeft
view.layer.add(transition, forKey: kCATransition)
I have a solution to propose if it suits your needs. 我有一个解决方案可以提出是否适合您的需求。 Instead of going with the rotation parameter you could play with the scale.
不用旋转参数,您可以使用比例尺。 You will have a faked rotation with no perspective whatsoever.
您将没有任何角度的假旋转。
Scale x for horizontal flip and Scale y for vertical. 缩放x用于水平翻转,缩放y用于垂直翻转。
You can do this as follow in view did load (or the button action function if you use a button to trigger the animation) : 您可以按照以下步骤执行此操作:在视图加载后(如果您使用按钮触发动画,则可以执行按钮操作功能):
UIView.animate(withDuration: 0.5) {
self.yourViewName.transform = CGAffineTransform(scaleX: -1, y: 1)
}
I hope it can help you. 希望对您有所帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.