围绕任意点旋转UIImageView

Jan*_*Jan 1 anchor uiimageview ios

我有一个UIImageView,我围绕它的中心旋转:

imageHorizon.layer.anchorPoint = CGPointMake(0.5, 0.5);
imageHorizon.transform = CGAffineTransformRotate(imageHorizon.transform, angleToRotate*(CGFloat)(M_PI/180));
Run Code Online (Sandbox Code Playgroud)

有时我也会将此图像向左或向右移动然后再旋转.我想一直保持旋转中心在同一点(实际上是超视图的中心).我怎样才能做到这一点 ?

干杯,

Bab*_*uli 5

self.imgView.layer.anchorPoint = CGPointMake(0.0,1.0);
self.imgView.layer.position = CGPointMake(100,200.0);
CGAffineTransform cgaRotateHr = CGAffineTransformMakeRotation(-(3.141/4));
[self.imgView setTransform:cgaRotateHr];
Run Code Online (Sandbox Code Playgroud)