简体   繁体   English

UIview动画中断了IOS

[英]UIview animation interrupted IOS

I am moving two UIButtons with this animation: 我正在用这个动画移动两个UIButton:

[UIView animateWithDuration:1.0
                              delay:0.0
                            options: UIViewAnimationCurveEaseInOut
                         animations:^{

                             self.ViewA.frame = CGRectMake(self.ViewA.frame.origin.x, self.ViewA.frame.origin.y - 174, self.ViewA.frame.size.width, self.ViewA.frame.size.height);
                             self.ViewB.frame = CGRectMake(self.ViewB.frame.origin.x, self.ViewB.frame.origin.y - 174, self.ViewB.frame.size.width, self.ViewB.frame.size.height);
                         }
                         completion:^(BOOL finished){

                         }];

but as the animation runs until the user holds his finger on a UIButton, if he releases the animation is interrupted. 但是随着动画的运行直到用户将手指按在UIButton上,如果他释放,动画就会中断。 Is there a method, or something to determine when this happens and fix the position of the buttons? 是否有一种方法或某种方法可以确定何时发生并确定按钮的位置?

In your completion block, the finished parameter tells you whether your animation has completed or not. 在您的完成块中, finished参数告诉您动画是否已完成。 If its value is NO , then the animation has been terminated. 如果其值为NO ,则动画已终止。 This is how you know if you need to fix the positions, etc. 这是您知道是否需要固定位置等的方式。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM