You want to be able to rotate the contents that you have drawn on a graphics context without changing your drawing code.
CGAffineTransformMakeRotation function to
create an affine rotation transformation.
I strongly suggest that you read the material in Recipes 17.11and in 17.12before proceeding with this section. To avoid redundancy, I have tried to keep material that has been taught in earlier sections out of later sections.
Just like scaling and translation, you can apply rotation
translation to shapes drawn on paths, and graphics contexts. You can use
function and pass the rotation value in radians to get back a rotation
transformation, of type
CGAffineTransform. You can then apply this
transformation to paths and shapes. If you want to rotate the
whole context by a specific angle, you must use the
Let’s rotate the same rectangle we had in Figure 17-27 45 degrees clockwise (see Figure 17-37). The values you supply for rotation must be in radians. Positive values cause clockwise rotation, while negative values cause counterclockwise rotation:
/* Rotate the rectangle 45 degrees clockwise */
/* Add the rectangle to the path */
As we saw in Recipe 17.12, we can also apply a transformation directly to a graphics ...