我想知道如何设置按钮的动画,例如Snapchat。当用户将凭据输入到这两个字段时(例如,当它们不为空时),它们会在以下位置为登录按钮设置动画:
有关如何做到这一点的任何建议?
答案 0 :(得分:0)
使用UIButton的imageView属性。您可以创建这样的动画:
[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];
答案 1 :(得分:0)
您可以使用animateWithDuration:
[UIView animateWithDuration:0.3f delay:0.0f options:UIViewAnimationOptionCurveEaseInOut animations:^{
[myButton setFrame:CGRectMake(0.0, 40.0, 320, 50)];
} completion:nil];