3

我正在尝试为我的应用程序创建一个拉出式襟翼。当您第一次点击图像/按钮时,我希望它动画出来以显示整个图像。当你再次点击它时,我希望它动画回到原来的位置。但是,我对如何实现这一点感到有些困惑。我想知道是否有办法让这个按钮用作开关,这样我就可以将它编程为简单地[在状态打开时执行此操作]和[在状态关闭时执行此操作]。非常感谢您的帮助!

4

1 回答 1

8
-(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;
 }
}
于 2011-03-08T08:35:20.923 回答