Objective c 设置UIButton动画

Objective c 设置UIButton动画,objective-c,ios,uibutton,core-animation,Objective C,Ios,Uibutton,Core Animation,是否可以设置ui按钮的动画 我想用我的按钮做的是像云一样对它进行动画处理,它只在给定的区域内来回移动 我已经尝试设置UIImages的动画,但我不知道UIButton是否也可以设置动画。UIView实例应该可以使用[UIView animateWithDuration:animations:设置动画。由于UIButton是UIView的一个子类,我没有预见到任何问题…正如前面所说的UIButton实例应该是可动画的,因为它是UIView的一个子类。下面的代码将前后移动ui按钮,即左右移动20像素

是否可以设置
ui按钮的动画

我想用我的按钮做的是像云一样对它进行动画处理,它只在给定的区域内来回移动


我已经尝试设置
UIImages
的动画,但我不知道
UIButton
是否也可以设置动画。

UIView
实例应该可以使用
[UIView animateWithDuration:animations:
设置动画。由于
UIButton
UIView
的一个子类,我没有预见到任何问题…

正如前面所说的
UIButton
实例应该是可动画的,因为它是
UIView
的一个子类。下面的代码将前后移动
ui按钮
,即左右移动20像素10次。基本上我把两个动画链接在一起

- (void)startLeftRightAnimation
{
[UIView animateWithDuration:0.5 
                      delay:0 
                    options:UIViewAnimationOptionCurveEaseIn 
                  animations:^(void) 
     {
         [self.button setFrame:CGRectMake(self.logo.frame.origin.x-20,self.logo.frame.origin.y,self.logo.frame.size.width,self.logo.frame.size.height)];
     } 
                  completion:^(BOOL finished) 
     {
         if(finished)
         {
             [UIView animateWithDuration:0.5 
                      delay:0 
                    options:UIViewAnimationOptionCurveEaseIn 
                  animations:^(void) 
             {
                 [self.button setFrame:CGRectMake(self.logo.frame.origin.x+40,self.logo.frame.origin.y,self.logo.frame.size.width,self.logo.frame.size.height)];
                 [self startLeftRightAnimation];
             }
                  completion:^(BOOL finished) 
         {
         if(finished)
         {
         }
     }];
}