如何翻转NSView的坐标系? [英] How do you flip the coordinate system of an NSView?

查看:340
本文介绍了如何翻转NSView的坐标系?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在接口构建器中创建了一个NSScrollView,该NSScrollView具有可变数量的半唯一NSView,可以通过编程方式从中添加和删除它们.当我将subView添加到documentView时,它们出现在左下角而不是左上角.我看到您可以检查isFlipped布尔值来确定视图的坐标系是否被翻转,但是我找不到找到将其设置为翻转状态的方法.

I have created an NSScrollView in interface builder that has a variable number of semi-unique NSViews that can be programmatically added and removed from it. When I add subViews to the documentView, they appear in the lower-left hand corner instead of the upper-left hand corner. I see that you can check the isFlipped bool to figure out if the view's coordinate system is flipped, but I cannot find a way to set it as flipped.

有人知道我想念什么吗?

Anyone know what I'm missing?

推荐答案

在您的NSView子类中,覆盖isFlipped:

isFlipped

一个布尔值,指示视图是否使用翻转的坐标系.

isFlipped

A Boolean value indicating whether the view uses a flipped coordinate system.

var isFlipped: Bool { get }

讨论

此属性的默认值为false,这将导致坐标系不翻转.

Discussion

The default value of this property is false, which results in a non-flipped coordinate system.

[...]

如果您希望视图使用翻转的坐标系,请覆盖此属性并返回true.

If you want your view to use a flipped coordinate system, override this property and return true.

来源: isFlipped-NSView | Apple开发人员文档

这篇关于如何翻转NSView的坐标系?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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