2014-02-12 106 views
0

我想知道如何動畫按鈕,例如snapchat。當用戶輸入他們的憑據在這兩個領域,如當他們是不是空的,他們在動畫的登錄按鈕:iOS中的動畫按鈕

enter image description here

任何建議就如何做到這一點?

回答

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]; 
0

您可以使用animateWithDuration:

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