Reputation: 2030
I'm developing an app for iOS where I have one image showing the degrees (from 0 to 180) and a second image representing a red arrow.
I want the arrow to simply rotate according to the input the user enters in a numeric field from 0 to 180.
At the moment the arrow rotates about its center (corresponding to the center of the arrow image), however I'd like the arrow to rotate from the bottom. In short, my question is: how can I rotate an image about an arbitrary point using Xcode and iOS SDK?
Here is an image I prepared to show visually the issue I'm having:
Upvotes: 2
Views: 753
Reputation: 7537
This is not as good of an aswer as konrads, but if time is an issue, another way to handle this is just make the needle image larger, and have 1/2 the image be transparent, then the auto anchorpoint would be in the center of the image.
Now:
______ | ^ | | | | -------
Make it
______ | ^ | | | | | | | | -------
Upvotes: 1
Reputation: 1786
I suggest looking into UIView
's transform
documentation and the anchorPoint
property:
The origin of the transform is the value of the center property, or the layer’s anchorPoint property if it was changed. (Use the layer property to get the underlying Core Animation layer object.) The default value is CGAffineTransformIdentity.
Upvotes: 5