Setting affine transform on NSView layer not working as on iOS

倖福魔咒の 提交于 2019-12-23 02:07:17

问题


I am trying to achieve something very simple. I would like to transform a layer's scale. However it does not seem to work as expected. In fact, it does not work at all. The layer's scale remains the same.

Here is my code:

NSView *v = [[NSView alloc]init];
v.wantsLayer = YES;
v.frame = self.bounds;
float scale = 0.8f;
[v.layer setAffineTransform:CGAffineTransformMakeScale(scale,scale)];
[self addSubview:v];

If I log the affineTransform property of v I get null.


回答1:


Try this on OSX:

self.layer.sublayerTransform = CATransform3DMakeScale(scale, scale, 0.0f);


来源:https://stackoverflow.com/questions/21218375/setting-affine-transform-on-nsview-layer-not-working-as-on-ios

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!