我是 iOS 开发中的动画新手。如何在iOS中将一个图像按钮设置为四个或五个按钮的顶部?每当我点击任何按钮时,图像按钮都必须放在该按钮的顶部。
问问题
279 次
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 outlet
和mvngButton
.
于 2012-06-18T13:19:23.073 回答