frank Williamson
frank Williamson

Reputation: 1

UIImage rotation axis

I want to rotate an image (UIImage) but can only do it from a default axis which is dead centre of the image ! as in Fig A. I want to move the axis to the centre of the x axis at the foot of the image as in Fig B. Can someone help me with this? I can only think of work arounds such as placing the image on an imaginary circle around the origin where the centre of the image would be where I position, then rotate the objects. This is too complicated and hopefully unneccessary. Imagine i want to place a number of images around a clock face with the origin in the centre where the clock hands originate, that's what I want to achieve. (The maths for doing this would also be appreciated).

(mid x axis and mid y axis).

Upvotes: 0

Views: 347

Answers (2)

Tarang
Tarang

Reputation: 626

I think you can do it by first rotating using CGContextRotateCTM and then shifting that center point to the point you want it to be by using CGContextTranslateCTM

Like rotate 90 degree first to right then shift center(x,y) to newPoint((x- width/2), (y - height/2)) here width and height are of rotated image.

I hope this helps.

Upvotes: 0

Related Questions