开发者

Quartz Framework (Mac) Explanation Needed

开发者 https://www.devze.com 2023-02-11 05:32 出处:网络
I have some labels I need to be rotated, and I asked a question earli开发者_StackOverflower about how to do so:

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

精彩评论

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