相关疑难解决方法(0)

有没有一种正确的方法来处理重叠的NSView兄弟姐妹?

我正在研究一个Cocoa应用程序,我遇到了一个我希望有两个NSView对象重叠的情况.我有一个父NSView,它包含两个子视图(NSView A和NSView B),每个子视图可以有几个自己的子视图.

有没有一种正确的方法来处理这种重叠?NSView B将始终位于NSView A的"上方",因此我希望屏蔽NSView A的重叠部分.

cocoa

16
推荐指数
2
解决办法
9505
查看次数

是否允许使用图层托管NSView进行子视图?

层托管NSView(因此您为其提供CALayer实例并将其设置为的NSView setLayer:)显然可以包含子视图.为什么显然?因为在Apple自己的Cocoa Slides示例代码项目中,您可以选中一个复选框,将复选框切换AssetCollectionView为图层托管:

- (void)setUsesQuartzCompositionBackground:(BOOL)flag {
    if (usesQuartzCompositionBackground != flag) {
        usesQuartzCompositionBackground = flag;

        /* We can display a Quartz Composition in a layer-backed view tree by 
           substituting our own QCCompositionLayer in place of the default automanaged 
           layer that AppKit would otherwise create for the view.  Eventually, hosting of 
           QCViews in a layer-backed view subtree may be made more automatic, rendering 
           this unnecessary.  To minimize visual glitches during the transition, 
           temporarily suspend window updates during …
Run Code Online (Sandbox Code Playgroud)

cocoa core-animation calayer nsview

7
推荐指数
1
解决办法
2180
查看次数

Cocoa 中的兄弟 NSView z-ordering

z-ordering 如何与 Cocoa 中的兄弟 NSViews 一起工作?我很困惑,因为我在 Apple 的文档和 API 中发现了相互矛盾的信息来源。(注意:子视图显然是在其父视图之上呈现的,我在这里明确地谈论兄弟视图)。

假设A“是的,你可以定义兄弟的z-order NSViews

  • IB你可以把对方的俯视图,他们将永远在你所希望的方式进行合成。
  • Xcode 中有Editor名为“Send to Back”、“Send Forward”等菜单下的按钮。
  • NSView也有一个命名的方法- (void)addSubview:(NSView *)aView positioned:(NSWindowOrderingMode)place relativeTo:(NSView *)otherView;,这似乎暗示,有一个明确的排序。

假设 B“不可能,兄弟的 z-orderNSViews在运行时是未定义的。有时有效,有时无效。不要相信它!”

  • Apple 的文档(查看编程指南)状态:For performance reasons, Cocoa does not enforce clipping among sibling views or guarantee correct invalidation and drawing behavior when sibling views overlap. If you want a view to be drawn in front of another …

macos cocoa core-graphics quartz-graphics

5
推荐指数
1
解决办法
4794
查看次数