2

我为我的 2 个按钮添加了摆动功能。和方法正常工作startWobblestopWobble

- (void)startWobble {
_hint1.transform = CGAffineTransformRotate(CGAffineTransformIdentity, RADIANS(-10));
_hint2.transform = CGAffineTransformRotate(CGAffineTransformIdentity, RADIANS(-10));

[UIView animateWithDuration:0.001
                      delay:0.0
                    options:(UIViewAnimationOptionAllowUserInteraction | UIViewAnimationOptionRepeat | UIViewAnimationOptionAutoreverse)
                 animations:^ {
                     _hint1.transform = CGAffineTransformRotate(CGAffineTransformIdentity, RADIANS(10));
                     _hint2.transform = CGAffineTransformRotate(CGAffineTransformIdentity, RADIANS(10));
                 }
                 completion:NULL
 ];
}

- (void)stopWobble {
[UIView animateWithDuration:0.25
                      delay:0.0
                    options:(UIViewAnimationOptionAllowUserInteraction | UIViewAnimationOptionBeginFromCurrentState | UIViewAnimationOptionCurveLinear)
                 animations:^ {
                     _hint1.transform = CGAffineTransformIdentity;
                     _hint2.transform = CGAffineTransformIdentity;
                 }
                 completion:NULL
 ];
}

但是,我在模拟器上测试了我的应用程序,当按钮开始摆动时,它们会推动靠近自己的其他按钮。然后按钮停止摆动,一切看起来都很好。我无法弄清楚问题所在。我使用过这些方法,以前从未遇到过这样的问题。

有什么建议么?

4

0 回答 0