By default, a UIImageView will rotate only about its center. How do I get it to rotate about any other point in the image?
相关问题
- CALayer - backgroundColor flipped?
- Core Data lightweight migration crashes after App
- How can I implement password recovery in an iPhone
- how do you prevent page scroll in textarea on mobi
- Custom UITableview cell accessibility not working
相关文章
- Could I create “Call” button in HTML 5 IPhone appl
- Xcode: Is there a way to change line spacing (UI L
- Unable to process app at this time due to a genera
- How do you detect key up / key down events from a
- “Storyboard.storyboard” could not be opened
- Open iOS 11 Files app via URL Scheme or some other
- Can keyboard of type UIKeyboardTypeNamePhonePad be
- Can not export audiofiles via “open in:” from Voic
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:
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:
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: