在NSView层上设置仿射变换无法像在iOS上那样工作 [英] Setting affine transform on NSView layer not working as on iOS

查看:158
本文介绍了在NSView层上设置仿射变换无法像在iOS上那样工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在努力实现非常简单的目标.我想改变图层的比例.但是,它似乎没有按预期方式工作.实际上,它根本不起作用.图层的比例保持不变.

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.

这是我的代码:

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

如果我登录vaffineTransform属性,则会得到null.

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

推荐答案

在OSX上尝试一下:

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

这篇关于在NSView层上设置仿射变换无法像在iOS上那样工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆