初始约束...
let conBottom = imageView.bottomAnchor.constraint(equalTo: view.bottomAnchor, constant: imageView.frame.height)
然后...
UIView.animate(
withDuration: 0.67,
delay: 2.0,
animations: {
conBottom.constant = imageView.frame.height
self.view.layoutIfNeeded()
},
completion: nil
)
相反的常数不会改变,但是动画会导致视图在屏幕末端消失。
如果我评论动画块中常数的设置,则视图不会移动。
为什么视图移动?
这是因为另一个约束在运行动画块之前会更改视图的高度。