Ios 按下一个按钮,它就会出现在屏幕上的其他地方
我有这个代码,所以它会改变位置一次,但当你仍然触摸时,它会停留在那里Ios 按下一个按钮,它就会出现在屏幕上的其他地方,ios,uibutton,Ios,Uibutton,我有这个代码,所以它会改变位置一次,但当你仍然触摸时,它会停留在那里 - (IBAction)fade { [UIView beginAnimations:nil context:NULL]; [UIView setAnimationDuration:0.5]; [button setAlpha: 0]; [UIView commitAnimations]; [UIView beginAnimations:nil context:NULL]; [U
- (IBAction)fade {
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.5];
[button setAlpha: 0];
[UIView commitAnimations];
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.5];
[button setAlpha: 1];
[UIView commitAnimations];
button.center = CGPointMake(152 + 16,326 + 16);
button.center = CGPointMake(200 + (kPlatformWidth/2),300 + (kPlatformHeight/2));
}
如何使其从此处转到随机位置?您不应使用beginAnimations:context: 引用文件: iOS 4.0及更高版本不鼓励使用此方法。你应该使用 使用基于块的动画方法来指定动画 您应该使用表单animateWithDuration:animations的新方法:
至于如何使按钮移动到随机位置,请使用arc4random_uniform计算新的x和y位置,并使用这些值作为视图中心的目标。首先。。。为什么不使用基于块的动画?