简体   繁体   English

子视图无旋转和缩放

[英]No rotation and scaling for subviews

I have one UIView with slider and segment control as a subview. 我有一个带有滑块和分段控件的UIView作为子视图。 I am using gesture control to handle rotation and scalling. 我正在使用手势控制来处理旋转和缩放。 Now while rotating uiview, the slider and segment control also get rotated. 现在,在旋转uiview时,滑块和细分控件也将旋转。 I dont want rotation and scaling for subviews. 我不希望旋转和缩放子视图。 Please help me to sort this issue. 请帮助我解决此问题。

Thanks 谢谢

Don't have your segmented control and slider as subviews of the scaled view. 不要将分段控件和滑块作为缩放视图的子视图。

If necessary, you could have a containing superview that contains the scaled view, segmented control and slider as subviews. 如有必要,您可以具有一个包含超级视图,该超级视图包含缩放视图,分段控件和滑块作为子视图。

You could "counter-rotate" your subviews when you handle the gesture for rotating the UIView. 处理旋转UIView的手势时,可以“反向旋转”子视图。

Create a CGAffineTransformRotate and apply it to your subview in case you do not want it to rotate: 创建一个CGAffineTransformRotate并将其应用于子视图,以防您不希望其旋转:

[UIView beginAnimations:nil context:nil];
CGAffineTransform transform = CGAffineTransformRotate(subview.transform, radians);
subview.transform = transform;
[UIView commitAnimations];

After you apply the transformation to the subviews, they will be rotated accordingly until you reset the transformation to its default value. 将转换应用于子视图后,它们将相应旋转,直到将转换重置为其默认值。

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

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