jeff
jeff

Reputation: 137

iPhone UIButton act like a UISwitch

I'm trying to create a pull out flap for my application. When you tap the image/button the first time, i want it to animate out to reveal the entire image. When you tap it again, i want it to animate back to its original location. I'm a little confused, however, on how to make this happen. I was wondering if there was a way to make this button function as a switch, so that i could program it to simply [do this when state is on] and [do this when state is off]. Help is greatly appreciated!

Upvotes: 3

Views: 682

Answers (1)

visakh7
visakh7

Reputation: 26390

-(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;
 }
}

Upvotes: 8

Related Questions