繁体   English   中英

UIView旋转和Subview(按钮)触摸

[英]UIView rotation and Subview (Button) touch

我有一个UIView ,在这个UIView我有8个按钮。 我每次都需要旋转此UIVIew因此我在使用以下代码:

CABasicAnimation *fullRotation = [CABasicAnimation animationWithKeyPath:@"transform.rotation"];
fullRotation.fromValue = [NSNumber numberWithFloat:0];
fullRotation.toValue = [NSNumber numberWithFloat:((360*M_PI)/180)];
fullRotation.duration = 30;
fullRotation.repeatCount = MAXFLOAT;
[self.menuView.layer addAnimation:fullRotation forKey:@"360"];

它可以正确旋转我的视图,但是我无法触摸旋转按钮。 由于父视图正在旋转,并且按钮也将旋转,因此触摸不起作用。 谢谢

因为您旋转图层。 我认为您无法完成所需的工作,但请尝试使用CGAffineTransform

CGAffineTransform transform //desired transform
[UIView animateWithDuration:time
                 animations:^{menuView.transform = transform;}];

并通过计时器调用它。

在动画过程中,普通视图触摸无法正常工作。 动画只会使视图看起来像在移动。 它们的实际坐标不动。

如果要支持点击对象,则需要使用表示层的hitTest方法在超级视图级别滚动自己的点击处理代码。

我在github上有一个示例项目,展示了如何执行此操作:

iOS核心动画演示

暂无
暂无

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

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