Hello Community 我只想为 UIView 和 UIButton 制作动画。但它真的不适合我。
self.introConstraints.constant = self.view.frame.width
self.view.needsUpdateConstraints()
UIView.animateWithDuration(0.6){
self.view.layoutIfNeeded()
}
这就是我的代码的样子。
最佳答案
=> 试试这个:-
UIView.animateWithDuration(0.6 , 动画: { self.button.transform = CGAffineTransformMakeScale(0.6, 0.6)
},
completion: {
UIView.animateWithDuration(0.6){
self.button.transform = CGAffineTransformIdentity
}
})
=> 如果你想用 Spring 动画获得更多的弹跳效果。:-
=>尝试下面的代码:
@IBOutlet 弱变量按钮:UIButton!
@IBAction func animateButton(sender: AnyObject) {
button.transform = CGAffineTransformMakeScale(0.6, 0.6)
UIView.animateWithDuration(2.0,
delay: 0,
usingSpringWithDamping: CGFloat(0.20),
initialSpringVelocity: CGFloat(6.0),
options: UIViewAnimationOptions.AllowUserInteraction,
animations: {
self.button.transform = CGAffineTransformIdentity
},
completion: { Void in() }
)
}
关于ios - 使用 Swift 自动布局动画 UIButton,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34618161/