سؤال

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