Scale UIView without scaling subviews

て烟熏妆下的殇ゞ 提交于 2019-12-10 03:54:45

问题


I'm trying to scale an UIView without scaling its subviews, or in my case I just want the subviews to be scaled in one axis. I need these hierarchy because I'm setting some Gesture Recognizers to detect panning and rotation and I want these to happen simultaneously with the parent view.

However, I don't want the scaling to happen simultaneously. For some subviews I want it to happen only vertically or horizontally or no scaling at all.

Is there a way to control the auto-scaling in an UIView's subviews when using CGAffineTransform on the UIView?


回答1:


If you ensure the autoresizingMask's of subviews is correctly set up, you can change the frame of the container UIView (it is animatable) and the subviews will not change size (if your resizing mask is correct). Turning off containerView.autoresizesSubviews and changing the frame should also work.




回答2:


Set the view's autoresizesSubviews to NO, by default it's YES.



来源:https://stackoverflow.com/questions/6636384/scale-uiview-without-scaling-subviews

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!