Search code examples
iosobjective-ccgaffinetransform

iOS : apply affine transform to subview only


I'm have a view-parent with one background image, which scaled to whole parent view. Also in view-parent i need to display some other views. So when i apply rotation to image :

[self.backgroundView setTransform:CGAffineTransformMakeRotation((CGFloat) M_PI)]; 

It rotates the whole parent view - so other subviews also rotated on 180 degrees

So, how can i apply rotation only to background view without affecting other views?


Solution

  • Well it sounds like your backgroundView has subviews that obviously would be transformed with parent, that's by design. What you need is to make your other views siblings of your background view. Make sure you're adding subviews to backgroundView's superview and not backgroundView itself.