简单动画

image.png

就是先讲它设为0,即隐藏
再设置时常
再恢复为初始状态

override func viewDidLoad() {
super.viewDidLoad()
ratingStackView.transform = CGAffineTransform(scaleX: 0, y: 0)
// Do any additional setup after loading the view.
}
override func viewDidAppear(_ animated: Bool) {
UIView.animate(withDuration: 1){
self.ratingStackView.transform = CGAffineTransform.identity
}
}

带震动的动画

UIView.animate(withDuration: 1, delay: 0, usingSpringWithDamping: 0.7, initialSpringVelocity: 0.8, options: [], animations: {
self.ratingStackView.transform = CGAffineTransform.identity
}, completion: nil)

后面两个至越大越接近,震动幅度越小,否则震动幅度越大(如0.3和0.5)

动画组合 位置和大小同时变动

image.png

你可能感兴趣的:(简单动画)