开发者

Quartz Framework (Mac) Explanation Needed

I have some labels I need to be rotated, and I asked a question earli开发者_StackOverflower 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


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)];


layer is a property of UIView and gives you an object of type CALayer to which you can apply a transformation, like

CALayer* layer = theLabel.layer;
[layer setAffineTransform:CGAffineTransformMakeRotation(M_PI)];

which will give you an upside down label.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜