IronManGill
IronManGill

Reputation: 7226

Increasing UIButton size temporarily on touch

Im creating an app which has 10 buttons and each has an IBAction to go into the next view. What I want is that on touch the size of the button increases till the user does not take his finger away. Also on double tap the IBAction is called. Now the question is should I use gestures for this ?

One solution is to change the buttons into imageviews and then use their methods in the gestures. But I want to keep the buttons likewise .... Any solution would be appreciated. Thanx.

Upvotes: 0

Views: 418

Answers (2)

Prabha
Prabha

Reputation: 434

Change the image of the button on touch .

[myButton setImage:[UIImage imageNamed:@"enter.png"] forState:UIControlStateNormal];

[myButton setImage:[UIImage imageNamed:@"enter-hover.png"] forState:U UIControlStateSelected];

Upvotes: 2

Pavel Oganesyan
Pavel Oganesyan

Reputation: 6924

You can also use myButton.transform = CGAffineTransformMakeScale(1.2, 1.2) then users put his finger on the button to avoid dupliction of images in your app (if it matters).. And make it back to (1.0, 1.0) then removes it. All can be done using addTarget:action:forControlEvents:. Read about it here

Upvotes: 3

Related Questions