IPhone UIButton acts like UISwitch

I am trying to create a flap for my application. When you first touch the image / button, I want it to animate to show the whole image. When you press it again, I want it to quicken to its original position. However, I'm a little confused on how to do this. I was wondering if there is a way to make this button function as a switch so that I can program it simply [do it when the state is on] and [do it when the state is off]. Help is much appreciated!

+3
source share
1 answer
-(IBAction)buttonClicked:(id)sender
{
 UIButton *button = (UIButton *)sender;
  if(button.tag==0)
 {
   // Do something to animate out to reveal the entire image
   button.tag = 1;
 }
 else if(button.tag==1)
 {
  // Do something else to animate back to its original location
   button.tag = 0;
 }
}
+8
source

All Articles