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

后端 未结 2 1658
感情败类
感情败类 2021-02-10 14:52

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条回答
  •  Happy的楠姐
    2021-02-10 15:11

    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.

提交回复
热议问题