stackiphone
stackiphone

Reputation: 1245

Resize a UIButton with touch events

How can we resize a UIbutton in IOS,i have a button with CGRectMake (30,50,120,200)when the application is running ,the user can taptohold or pinch gesture to make the button big or small according to his needs.lke the zooming function of scrollview ..How to do this.thanks in advance.

Upvotes: 2

Views: 762

Answers (2)

calimarkus
calimarkus

Reputation: 9977

Use an UIPinchGestureRecognizer on the button to detect the gesture. Then resize the frame, or use an AffineTransform. (button.transform = CGAffineTransformMakeScale(scaleFactor,scaleFactor)).

Upvotes: 2

ultragtx
ultragtx

Reputation: 957

Use the CGAffineTransformMakeScale like this

button.transform = CGAffineTransformMakeScale(1.2, 1.2)

scale it to normal

button.transform = CGAffineTransformMakeScale(1.0, 1.0)

If you want animation

[UIView animateWithDuration:0.3
                     animations:^{
                         button.transform = CGAffineTransformMakeScale(1.2, 1.2);
                     }
                     completion:NULL];

Upvotes: 3

Related Questions