=>嘗試這一個: -
UIView.animateWithDuration(0.6, 動畫: { self.button.transform = CGAffineTransformMakeScale(0.6,0.6)
},
completion: {
UIView.animateWithDuration(0.6){
self.button.transform = CGAffineTransformIdentity
}
})
=>如果您想用彈簧動畫更多彈跳效果:-
=> tr y folowing code:
@IBOutlet weak var button: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() }
)
}
漏下'self.view.needsUpdateConstraints()',它應該工作。如果你用'self.view.setNeedsUpdateConstraints()'替換它,那麼你一定不要調用這個方法。 – borchero