开发者

CGAffineTransforms on NSViews

开发者 https://www.devze.com 2023-03-17 06:09 出处:网络
I am trying to port some iOS code to Mac OS X. I am having trouble 开发者_开发问答porting this though,

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

精彩评论

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