【问题标题】:Shrink and Transform UIButton缩小和变换 UIButton
【发布时间】:2015-01-04 08:16:24
【问题描述】:

我试图在单击时改变我的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)
    })

}

【问题讨论】:

    标签: ios animation uibutton animatewithduration


    【解决方案1】:

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

    button.transform = CGAffineTransformMakeScale(0.5, 0.5);
    

    【讨论】:

    • 谢谢。但是当我第二次点击它时,它就离开了屏幕。如何防止它从屏幕上消失?
    • 按钮每左移75点,检查button.frame.origin.x - 75是否大于0。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-07-02
    • 1970-01-01
    • 2012-09-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多