缩放UIButton动画 - Swift [英] Scale UIButton Animation- Swift
本文介绍了缩放UIButton动画 - Swift的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图在点击时为 UIButton
做缩放动画,但我想要完成的是点击按钮时我需要 UIButton
要小到内部然后又恢复到相同的大小(如泡泡)。
I'm trying to do scale animation for UIButton
when its clicked but what I'm trying to accomplish is when the button clicked I need the UIButton
to be smaller to the inside then it comes back to its same size (like a bubble).
我尝试了以下内容:
button.transform = CGAffineTransformMakeScale(-1, 1)
UIView.animateWithDuration(0.5, animations: { () -> Void in
button.transform = CGAffineTransformMakeScale(1,1)
})
推荐答案
试试这个
UIView.animate(withDuration: 0.6,
animations: {
self.button.transform = CGAffineTransform(scaleX: 0.6, y: 0.6)
},
completion: { _ in
UIView.animate(withDuration: 0.6) {
self.button.transform = CGAffineTransform.identity
}
})
这篇关于缩放UIButton动画 - Swift的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文