Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Scale UIView without scaling subviews

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?

like image 309
jglievano Avatar asked Jul 09 '11 17:07

jglievano


1 Answers

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.

like image 102
Benjamin Mayo Avatar answered Sep 25 '22 16:09

Benjamin Mayo