Note that there are some explanatory texts on larger screens.

plurals
  1. POScaling an UIButton vertically only from the bottom
    primarykey
    data
    text
    <p>I'm trying to animate the scaling of an UIButton but am having difficulties getting it to animate the way I want it to. </p> <p>I have a UIButton set up with a stretchable UIImage. I want its height to scale to a certain size and give it the effect that it is 'growing'. I use the code below, but it animates the UIButton growing from top and bottom, rather than just bottom. See the code here:</p> <pre><code>myButton.transform = CGAffineTransformMakeScale(1,0.5); myButton.alpha = 0.6f; [UIView beginAnimations:@"myButton" context:nil]; [UIView setAnimationDuration:0.5]; myButton.transform = CGAffineTransformMakeScale(1,1); myButton.alpha = 1.0f; [UIView commitAnimations]; </code></pre> <p>It's hard to explain, basically I want the UIButton to grow from only one side (the bottom) rather than it grow by expanding both sides. Any suggestions?</p> <hr> <p>UPDATE</p> <p>I also tried changing the button's frame and that did not work either. This time, no animation was seen at all. This is my code:</p> <pre><code>CGRect buttonRect = CGRectMake(0, 0, 150, 22); UIButton *myButton = [UIButton buttonWithType:UIButtonTypeCustom]; myButton.frame = buttonRect; myButton.alpha = 0.6f; [self.view addSubview:myButton]; [UIView beginAnimations:@"myButton" context:nil]; [UIView setAnimationDuration:0.3]; CGRect buttonRect2 = CGRectMake(0, 0, 150, 52); myButton.frame = buttonRect2; myButton.alpha = 1.0f; [UIView commitAnimations]; </code></pre> <p>Any ideas why it is not animating at all? I'm assuming it has something to do with how I'm setting the frame?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload