bezierPath use transformUsingAffineTransform How does the rotation(transform rotateByRadians) set around its own center point instead of the default 0,0 point of the view?
To use a different transformation origin, first move the Bézier path (“translate” x and y coordinates), rotate, and then move (translate) back. After the first translation, the point that you want to rotate around must be at position (0, 0).
For example, to rotate around the center of the object, translate x by −50% of its width − the x position of the object and y by −50% of its height − the y coordinate of its position, rotate, and then translate it back with −x and −y.
You can do it like this:
NSAffineTransform *transform = [NSAffineTransform new]; [transform translateXBy:center.x yBy:center.y]; [transform rotateByDegrees:angle]; [transform translateXBy:-center.x yBy:-center.y]; [bezierpath transformUsingAffineTransform: transform];
I see. Thank you very much!
Also thank you very much for your example!