views:

80

answers:

2

I've tried creating two UIButtons programatically as described here. This works great but there doesn't seem to be a simple transition for expanding the UIButton on the left as seen in the Apps Store.

A: 

If you would like to animate the size of your button, you can use transforms or make the frame larger. Just set the new frame or transform, start the animation, and your button should animate to it's new size.

Charybdis
Would you mind explaining you suggestion further. It doesn't seem to take into consideration that two buttons are required. Currently I have one smaller button with a different background PNG that is put into a UIView container. I then have a larger second button which is swapped in the the UIView container for the smaller one but the transformation does not animate.
Jim
Instead of using two different buttons, just use one button and animate it's frame. You can change the text of your button in the animation, and then it should look similar to the app store's install button.
Charybdis
I've checked the documentation [here](http://developer.apple.com/iphone/library/documentation/GraphicsImaging/Reference/CALayer_class/Introduction/Introduction.html#//apple_ref/occ/instp/CALayer/frame) and it says the frame can not be animated. Perhaps I'm missing your point?
Jim
A: 

Assuming your button starts as 50 wide, 38 high and is at the 100,100 point of the screen:

[UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:.5];
    yourButton.frame = CGRectMake(70, 100, 80, 38); // this makes the button 80 wide, expanding to the left
    //here you can change other values, such as the background image and title.
    [UIView commitAnimations];
Alan Taylor