Search code examples
objective-cxcodemacosinterface-builderquartz-graphics

Quartz Framework (Mac) Explanation Needed


I have some labels I need to be rotated, and I asked a question earlier about how to do so:

Rotating Labels

Apparently the best way to do this is via the layer property of the Quartz Framework? Can someone give a newbie an explanation on how to do this? :) I will award an answer quickly!

Zach


Solution

  • You could simply use NSView's setBoundsRotation: method to set it without CoreAnimation.

    If you really want to use CoreAnimation you would go like this:

    // make NSView myView a layer-backed view
    [myView setWantsLayer:YES];
    // now get that CALayer and set the affineTransform of it, specifying the angle
    [myView.layer setAffineTransform:CGAffineTransformMakeRotation(M_PI)];