As others have said, NSRect or CGRect always a rectangle with an axis . CGRectApplyAffineTransform returns the axis-aligned bounding box of the translated rectangle:

Note that the new rectangle (bounding box) may have different sizes than the original rectangle if you applied the rotation. This means that using a rectangle to transform a transformed rectangle is useless.
Instead, you need to transform the coordinate system of the graphics context. Think of it this way: you draw a piece of paper on a table. You always draw a rectangle that is aligned with the edges of the table. To draw a rotating rectangle, you rotate the paper and then draw a rectangle, as usual. Changing the CTM is like turning (or moving or squeezing or expanding) a sheet of paper.
-(void)drawRect:(NSRect)rect { CGContextRef gc = [[NSGraphicsContext currentContext] graphicsPort];
source share