How to zoom a view in UIScrollView with anchor point in center?

后端 未结 2 1726
暗喜
暗喜 2021-02-10 14:51

I have a view in UIScrollView in which the user can zoom into.

The view has the same size as the UIScrollView frame. However, the subviews of that view are bigger and ce

2条回答
  •  一个人的身影
    2021-02-10 15:21

    Yes I believe you can change the anchorPoint for a view's layer. like so -

    [self.yourView.layer setAnchorPoint:CGPointMake(0.5, 0)];
    

    The coordinates of the anchor point are aptly defined in this diagram -

    enter image description here

    If you want the animation to anchor from left-center then set the anchorPoint to (0.0, 0.5) i.e. point B in the figure.

提交回复
热议问题