how to rotate UIIMageVIew with fix point?

后端 未结 3 535
时光取名叫无心
时光取名叫无心 2021-01-15 11:52

I want to rotate image on angle.But i wnt to rotate image with fix point.How can i set this fix point?

3条回答
  •  太阳男子
    2021-01-15 12:37

    Set the view's layer's anchorpoint, which is in view-local coordinates from 0 to 1. That is, the top left is 0,0 and the bottom right is 1,1.

    For example, the default is to rotate around the center:

    imageView.layer.anchorPoint = CGPointMake(.5,.5);
    

    If you want to rotate around the origin:

    imageView.layer.anchorPoint = CGPointMake(0,0);
    

    Or the middle right edge:

    imageView.layer.anchorPoint = CGPointMake(1,.5);
    

提交回复
热议问题