问题描述
我在接口构建器中创建了一个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
:
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
.
这篇关于如何翻转NSView的坐标系?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!