StevenZ
StevenZ

Reputation: 7113

Shrink and Transform UIButton

I am trying to transform my UIButton left when clicked, and I want it to shrink at the same time as well. I have tried the following code, and it does transform left, but I do not know how to shrink the button. How could I shrink and transform the 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)
    })

}

Upvotes: 0

Views: 832

Answers (1)

gabbler
gabbler

Reputation: 13766

You can add this code inside your animation block. Which scale the button to half of its size.

button.transform = CGAffineTransformMakeScale(0.5, 0.5);

Upvotes: 2

Related Questions