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?

有帮助吗?

解决方案

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

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top