One way of doing this is by changing the anchorPoint of the UIImageView's underlying layer and rotating about that. You can change the point of rotation using something like the following:
imageView.layer.anchorPoint = CGPointMake(0.25, 0.25);
anchorPoint is defined in terms of relative coordinates within the layer. That is, (0,0) is the upper-left of the layer (on the iPhone, where UIView layers have flipped Y coordinates) and (1,1) is the lower-right.
Moving the anchorPoint may move your image, so you might need to adjust its position afterwards.
To rotate the image's layer about that new anchor point, you can change the CATransform3D struct for the layer using something like the following:
CATransform3D rotatedTransform = imageView.layer.transform;
rotatedTransform = CATransform3DRotate(rotatedTransform, 60.0 * M_PI / 180.0, 0.0f, 0.0f, 1.0f);
imageView.layer.transform = rotatedTransform;
This example does an incremental rotation of 60 degrees about the anchor point.
All changes to a layer are animated by default. You can disable this animation by enclosing your changes to these properties in a CATransaction like the following:
[CATransaction begin];
[CATransaction setValue:(id)kCFBooleanTrue forKey:kCATransactionDisableActions];
// Code for changes here
[CATransaction commit];
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…