你好社区我只想动画一个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=cgafinetransformmakescale(0.6,0.6)
},
completion: {
UIView.animateWithDuration(0.6){
self.button.transform = CGAffineTransformIdentity
}
})
=>如果你想在弹簧动画中获得更多的反弹效果:-
=>尝试下列代码:
@IBOutlet弱变量按钮:UIButton!
@IBAction func animateButton(发件人: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/