ios - Animate UIButton Down - Xcode -


i wanted know how go animating uibutton down when clicked via

-(ibaction) 

thanks in advance!

inside ibaction

uibutton *button = (uibutton*)sender;  //animates button 25 pixels right , 25 pixels down. customize cgrect newframe = cgrectmake(button.frame.origin.x + 25, button.frame.origin.y + 25, button.frame.size.width, button.frame.size.height);  [uiview animatewithduration:0.3f                       delay:0.0f                     options: uiviewanimationoptioncurvelinear                  animations:^{                      [button setframe:newframe];                  }                  completion:nil]; 

edit - toggle between frames

initialize boolean clicked no somewhere

if (!clicked){      //animates button 25 pixels right , 25 pixels down. customize     cgrect newframe = cgrectmake(button.frame.origin.x + 25, button.frame.origin.y + 25, button.frame.size.width, button.frame.size.height);      [uiview animatewithduration:0.3f                           delay:0.0f                         options: uiviewanimationoptioncurvelinear                      animations:^{                          [button setframe:newframe];                      }                      completion:nil];       clicked = yes;  } else {       //animates button 25 pixels left , 25 pixels up. customize     cgrect newframe = cgrectmake(button.frame.origin.x - 25, button.frame.origin.y - 25, button.frame.size.width, button.frame.size.height);      [uiview animatewithduration:0.3f                           delay:0.0f                         options: uiviewanimationoptioncurvelinear                      animations:^{                          [button setframe:newframe];                      }                      completion:nil];      clicked = no;  } 

Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -