0

i am wondering how to animate a button in, an example is snapchat. When the user enters their credentials in to both fields, as in when they are not empty, they animate the login button in:

enter image description here

Any suggestions on how this is done?

Xu Yin
  • 3,932
  • 1
  • 26
  • 46

2 Answers2

0

Use the imageView property of UIButton. You can create an animation like this:

[myButton setImage:[UIImage imageNamed:@"1.png"] forState:UIControlStateNormal];
myButton.imageView.animationImages = [NSArray arrayWithObjects:
                                  [UIImage imageNamed:@"1.png"],
                                  [UIImage imageNamed:@"2.png"],
                                  [UIImage imageNamed:@"3.png"],
                                  [UIImage imageNamed:@"4.png"],
                                  [UIImage imageNamed:@"5.png"],
                                  nil];

myButton.imageView.animationDuration = 0.5;
[myButton.imageView startAnimating];
sangony
  • 11,636
  • 4
  • 39
  • 55
0

You can use animateWithDuration:

[UIView animateWithDuration:0.3f delay:0.0f options:UIViewAnimationOptionCurveEaseInOut animations:^{
    [myButton setFrame:CGRectMake(0.0, 40.0, 320, 50)];
} completion:nil];
Sean
  • 1,534
  • 12
  • 20