【发布时间】:2017-06-05 19:23:56
【问题描述】:
我正在以编程方式创建一个自定义视图,它工作正常,然后我正在尝试为视图设置动画。出于某种奇怪的原因,视图完全是动画的,我不知道为什么。代码如下:
override func viewDidLoad() {
super.viewDidLoad()
let customView = UIView(frame: CGRect(x: 10, y: 10, width: 100, height: 100))
customView.backgroundColor = UIColor.blue
customView.layer.cornerRadius = 25
customView.layer.borderWidth = 8
customView.layer.borderColor = UIColor.red.cgColor
self.view.addSubview(customView)
UIView.animate(withDuration: 4, animations: {
customView.transform.translatedBy(x: 40, y: 60)
customView.transform.rotated(by: CGFloat.pi/2)
customView.transform.scaledBy(x: 0, y: 0.5)
})
}
【问题讨论】:
标签: ios swift uiview transform uianimation