I need to create a circular rating meter in iOS, it\'s like a UISlider only curved 3/4 around a circle. I need to rotate a UIImageView (which is the rating needle) around an
Have you tried using the anchorPoint
property of the UIImageView
's underlying layer? If you have a CGPoint
representing the point (in your image view's coords) around which it is to rotate, you can set the layer's anchor point:
CGRect imageBounds = self.needleImageView.bounds;
[self.needleImageView.layer setAnchorPoint:CGPointMake(rotationPoint.x / imageBounds.size.width, rotationPoint.y / imageBounds.size.height)];
Ensure that the image view's center
property is set to the appropriate position also, and then apply the rotation transform to rotate about the layer's anchor point:
self.needleImageView.transform = CGAffineTransformRotate(self.needleImageView.transform, angleInRadians);
Remember that you need to import <QuartzCore/QuartzCore.h>
in order to access the layer's properties.