I have a CGRect which I have rotated using translation and rotation function as below:-
let ctx: CGContext = UIGraphicsGetCurrentContext()!
ctx.saveGState()
let halfWidth = (selectedCropRect?.size.width)! / 2.0
let halfHeight = (selectedCropRect?.size.height)! / 2.0
let center = CGPoint(x: (selectedCropRect?.origin.x)! + halfWidth, y: (selectedCropRect?.origin.y)! + halfHeight)
// Move to the center of the rectangle:
ctx.translateBy(x: center.x, y: center.y)
// Rotate:
ctx.rotate(by: rotationAngle!);
// Draw the rectangle centered about the center:
let rect = CGRect(x: -halfWidth, y: -halfHeight, width: (selectedCropRect?.size.width)!, height: (selectedCropRect?.size.height)!)
let path = UIBezierPath(rect: rect).cgPath
ctx.addPath(path)
ctx.restoreGState()
Now the problem is i need to get all the corner points of the rotated rect and place circular views on the corner points so that the user can drag the corner points and increase/decrease size of rect. Any idea how i can place the circular views on the 4 corner points of rotated rect?
Untested but this should help point you in the right direction