0
votes

I have three UIViews (A, B, C) where A contains B and C. I want to be able to scale view B, by detecting a Pinch gesture with a UIPinchGestureRecognizer and then using CGAffineTransformScale to scale view B.

However, when I scale B it scales OK, but expands outside its original area of the screen - I'd like to keep the area of the screen which contains B the same and just show a smaller piece of it, but magnified.

Is there something I can set to keep the view's area the same?

1
Could be that your view A is set to not clip subviews. Without more details we can't be sure.CrimsonChris
how would i set this? is it a property on view A?Flaming Moe
Yes, it's a property. It prevents any of its subviews from drawing outside of its bounds. If you are sure that A isn't changing its size then this is likely the issue.CrimsonChris

1 Answers

0
votes

You can use

viewA.clipsToBounds = YES;

With clipsToBounds set to YES, you will see the part of the viewB and viewC that fits within the bounds of the viewA. Otherwise, if clipsToBounds is set to NO, you will see the entire viewB and viewC, even the parts are outside the viewA