我有一个简单的LottieAnimationView
,我想将它旋转90度,但.transform
没有任何影响。正在显示它,但未应用转换。
我是这样设置的:
self.view.addSubview(arrowAnimation)
arrowAnimation.translatesAutoresizingMaskIntoConstraints = false
arrowAnimation.heightAnchor.constraint(equalToConstant: screenSize.width/3).isActive = true
arrowAnimation.bottomAnchor.constraint(equalTo: introLabel.topAnchor, constant: -20).isActive = true
arrowAnimation.centerXAnchor.constraint(equalTo: view.centerXAnchor).isActive = true
arrowAnimation.contentMode = .scaleAspectFit
arrowAnimation.transform.rotated(by: .pi / 2)
arrowAnimation.animationSpeed = 1.5
arrowAnimation.loopMode = .playOnce
你知道为什么transform
在这里不能工作吗?
发布于 2020-10-12 02:51:51
下面的方法将会起作用:
arrowAnimation.transform = CGAffineTransform(rotationAngle: CGFloat.pi/2)
至于原因:
.transform.rotated(by:.pi/2)返回一个转换,但不应用它,因此您需要改为执行以下操作:
arrowAnimation.transform = arrowAnimation.transform.rotated(by: .pi/2)
https://stackoverflow.com/questions/64307512
复制相似问题