如何去除“模糊”可可添加到透明片材上的效果?

发布于 2024-09-12 18:01:02 字数 661 浏览 3 评论 0原文

默认情况下,当透明和半透明模态表应用于窗口时,Cocoa 会为其添加背景模糊效果。我想禁用模糊效果。我该怎么做呢?

我创建了一个自定义工作表(NSWindow 的子类,具有透明背景和其中的一些控件)。我可以使用标准 beginSheet 方法显示它,如下所示:

[NSApp beginSheet:myCustomSheet
   modalForWindow:mainWindow
    modalDelegate:self
   didEndSelector:...];

工作表显示正常,但其后面的所有内容都模糊。

注 1: 我正在为触摸屏/信息亭类型的应用程序编写完全定制的用户界面,因此通常的 Apple 用户界面指南均不适用。

注2:确实想看看床单下面有什么。正如 SirRatty 指出,可以通过填充背景来遮挡模糊部分。就我而言,我想让背景显示出来,但又不显得模糊。

By default, Cocoa adds a background blur effect to transparent and semitransparent modal sheets when they are applied to a window. I would like to disable the blur effect. How would I go about doing it?

I have created a custom sheet (a subclass of NSWindow with a transparent background and some controls in it). I am able to display it using the standard beginSheet method as follows:

[NSApp beginSheet:myCustomSheet
   modalForWindow:mainWindow
    modalDelegate:self
   didEndSelector:...];

The sheet displays fine, but everything behind it is blurred.

Note 1: I am writing a completely customized user interface for a touch screen / kiosk type app, so none of the usual Apple user interface guidelines apply.

Note 2: I do want to see what is underneath the sheet. As SirRatty pointed out, it is possible to block out the blurred portion by filling in the background. In my case, I want to have the background show through, just without appearing blurred.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

初见你 2024-09-19 18:01:03

有一个私有 API 调用可用于在窗口背景上设置 CI 过滤器:

还有一个 CGSRemoveWindowFilter

extern CGError CGSRemoveWindowFilter(CGSConnectionID cid, CGSWindowID wid, CGSWindowFilterRef filter);

请注意,通常的私有 API 警告适用(可能会消失)或将来发生变化等)。

There's a private API call that can be used to set a CI filter on the background of a window:

http://www.mail-archive.com/[email protected]/msg16280.html

There's also a CGSRemoveWindowFilter:

extern CGError CGSRemoveWindowFilter(CGSConnectionID cid, CGSWindowID wid, CGSWindowFilterRef filter);

Just be aware that the usual private API caveats apply (might go away or change in the future, etc.).

匿名的好友 2024-09-19 18:01:03

我所做的:

在 IB 中,将一个窗口大小的自定义 NSView 添加到窗口中内容视图层次结构的底部。将对象的类设置为 MySolidView(或其他)。

在 Xcode 中,MySolidView 类只做一件事:在 -drawRect 上,它将用纯色填充视图。 (例如浅灰色)。

What I've done:

In IB, add a window-sized custom NSView to the window, at the bottom of the content view hierarchy. Set the object's class to MySolidView (or whatever.)

In Xcode, the MySolidView class does just one thing: on -drawRect it will fill the view with a solid color. (e.g. light grey).

深海蓝天 2024-09-19 18:01:03

您可以编写自己的工作表动画例程来显示您自己的 NSWindow 并用半透明颜色填充窗口的背景。我不确定 NSWindowsetAlphaValue: 是否也会影响子元素的不透明度。如果它确实影响它们,您可以使用 setBackgroundColor: 并提供默认的窗口背景颜色,但使用 alpha 组件,这不应影响子元素。

我想开发/设计自己的用户界面的问题之一是当你必须重新实现轮子只是为了一个小的定制。至少,如果你自己编写它,你将来可以更好地控制它的定制。

You could write your own sheet animation routines that display your own NSWindow and fill the background of the window with a semitransparent colour. I'm not sure whether setAlphaValue: for NSWindow will also affect the child elements' opacity. If it does affect them, you could use setBackgroundColor: and provide the default window background colour but with an alpha component, this should not affect the child elements.

I suppose one of the problems of developing/designing your own user interface is when you have to reimplement the wheel just for a minor customisation. At least, if you write it yourself, you'll have more control over its customisation in the future.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文