开发者

CGAffineTransforms on NSViews

I am trying to port some iOS code to Mac OS X. I am having trouble 开发者_开发问答porting this though,

CGAffineTransform transform = CGAffineTransformMakeRoatation(-b->GetAngle());    
oneView.transform = transform

How can I achieve this? The NSView doesn't have a transform property.


You still can use transformations.

Make sure your view is layer-backed by setting setWantsLayer: on your view to YES.

Afterwards, you can just set the layer's affine transform:

CGAffineTransform transform = CGAffineTransformMakeRotation(-b->GetAngle());    
[[oneView layer] setAffineTransform: transform];


The only way i found to rotate NSView with core animation is

[myView setFrameCenterRotation:angle]

but be carefull using this method. it works correct only if myView is added to a superview. you can track this by overriding method – viewWillMoveToSuperview:

Enjoy)

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜