缩小和转换UIButton

时间:2015-01-04 08:16:24

标签: ios animation uibutton animatewithduration

我试图在点击时转换我的UIButton左边,我希望它同时缩小。我尝试了以下代码,它确实向左转换,但我不知道如何缩小按钮。我怎样才能缩小和转换UIButton

@IBAction func joinCircleButton(sender: AnyObject) {
    let button = sender as UIButton

    UIView.animateWithDuration(1.0, animations:{
        button.frame = CGRectMake(button.frame.origin.x - 75, button.frame.origin.y,button.frame.size.width, button.frame.size.height)
    })

}

1 个答案:

答案 0 :(得分:2)

您可以在动画块中添加此代码。将按钮缩放到其大小的一半。

button.transform = CGAffineTransformMakeScale(0.5, 0.5);