0

我是 iOS 开发中的动画新手。如何在iOS中将一个图像按钮设置为四个或五个按钮的顶部?每当我点击任何按钮时,图像按钮都必须放在该按钮的顶部。

4

2 回答 2

0

通过给予将按钮放在前面

[self.view bringSubViewToFront:buttonName];

并像这样实现动画

CGRect basketBottomFrame = basketBottom.frame;
basketBottomFrame.origin.y = self.view.bounds.size.height;

[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.5];
[UIView setAnimationDelay:1.0];
[UIView setAnimationCurve:UIViewAnimationCurveEaseOut];

basketTop.frame = basketTopFrame;
basketBottom.frame = basketBottomFrame;

[UIView commitAnimations];
于 2012-06-18T13:03:11.347 回答
0

在 .h 文件中,将 imageButton 声明为:

    int selectedCurveIndex;
    @property(nonatomic,retain)IBOutlet UIButton *mvngButton;
   -(IBAction) btnMoveTo:(id)sender;
-(IBAction) btnDownUnder:(id)sender;

在 .m 文件中,

static int curveValues [] = {
UIViewAnimationOptionCurveEaseInOut,
UIViewAnimationOptionCurveEaseIn,
UIViewAnimationOptionCurveEaseOut,
UIViewAnimationOptionCurveLinear};

   -(IBAction) btnMoveTo:(id)sender
{
UIButton *btn=(UIButton *)sender;
[mvngButton moveTo: CGPointMake(btn.center.x - (mvngButton.frame.size.width/2),btn.frame.origin.y - (mvngButton.frame.size.height + 5.0))duration:2.0 option:curveValues[selectedCurveIndex]];
}
-(IBAction) btnDownUnder:(id)sender
{
UIButton *btn=(UIButton *)sender;
[btn downUnder:1.0 option:curveValues[selectedCurveIndex]];
}

对于剩下的四个按钮,在xib文件中,touchupinside-(IBAction) btnMoveTo:(id)sender方法。对于 xib 文件中的 imageButton,touch up inside方法与-(IBAction) btnDownUnder:(id)sender方法referencing outletmvngButton.

于 2012-06-18T13:19:23.073 回答