I’ve subclassed a UIView as an avatar-object, which contains an icon (UIImageView), name (UILabel) and ID (UILabel). Depending on the orientation X,Y coordinates, I want the icon to be rotated. For example, say orientation.X = 1 and orientation.Y = 1 would give 45 degrees angle. X and Y could be anything between -1 and 1.
I’m not sure how it is calculated mathematically nor the cocoa API calls for it. Any ideas where to start?
for smoothness i added an animation:
EDIT:
for other angles you need to create your own rotation matrix.
How rotation matrix works
Read here how to create a custom affine transformation in Objective-c
Hope this helps.