I have an uiimage and i rotated the image using CGAffineTransformMakeRotation to the desired angle. Now i wanted to find out the new coordinates of the image that is new x position, y position, width, height of the image using the imageview.center method
Asked
Active
Viewed 254 times
1 Answers
0
Since you are asking for x, y, width, height and not the four corners I'm assuming that you want the bounding box of the rotated image. You could calculate that using a CGPath.
// Your rotation transform
CGAffineTransform rotation = CGAffineTransformMakeRotation(angle);
// Create a path from the transformed frame
CGPathRef rotatedImageRectPath =
CGPathCreateWithRect(
imageView.frame, // rect to get the path from
&rotation // transform to apply to rect
);
// Get the bounding box from the path
CGRect boundingBox = CGPathGetBoundingBox(rotatedImageRectPath);

David Rönnqvist
- 56,267
- 18
- 167
- 205