弹出窗口中的 NSScrollView 在 MacOS Mojave 下变得透明 [英] NSScrollView in a popup became transparent under MacOS Mojave

查看:46
本文介绍了弹出窗口中的 NSScrollView 在 MacOS Mojave 下变得透明的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在一个显示为 Popover 的视图中,我实现了一个帮助子视图(一个 NSView,一个 NSScrollView 作为一个子视图),当用户点击一个按钮时会出现这个帮助子视图.与塞拉&High Sierra,一切正常,但是自从我将 dev MacPro 升级到 Mojave 后,帮助气泡变得略微透明.作为帮助视图的元素(NSTextField 或 NSButton)在深色模式下仍显示为白色条带(或在浅色模式下显示为灰色条带)

In a view displayed as a Popover, I implement a help subview (a NSView with a NSScrollView as a subview) that appears when user click on a button. With Sierra & High Sierra, everything was all right, but since I upgraded the dev MacPro to Mojave, the help bubble became slightly transparent. Elements (NSTextField or NSButton) being the help view are still visible as a white strip in Dark Mode (or as a gray strip in Light Mode)

我已经定义了帮助视图和它的滚动视图有自己的层,这两个层被设置为不透明

I have defined the help view and its scroll view to have their own layer and these two layers are set as opaque

[help setWantsLayer:YES];
help.layer.opaque = TRUE;
help.backgroundColor = [NSColor colorWithRed:1. green:1. blue:140./255. alpha:1.];
[help.scrollView setWantsLayer:YES];
help.scrollView.layer.opaque = TRUE;
[help.scrollView setBackgroundColor:[NSColor colorWithRed:1. green:1. blue:140./255. alpha:1.]];

所有背景颜色都设置为这种黄色调.仅当显示帮助视图的视图显示为 NSPopover,而不是来自普通窗口的 NSView 时,才会出现此问题.有什么想法吗?

All background colours are set to this yellow tone. This problem occurs only if the view that display the help view was presented as a NSPopover, not as a NSView from an ordinary window. Any idea?

推荐答案

add NSRequiresAquaSystemAppearance = YES in your info.plist

add NSRequiresAquaSystemAppearance = YES in your info.plist

要在深色模式下运行任何应用程序,您必须运行 macOS Mojave 10.14 或更高版本.默认情况下,即使系统配置为在深色模式下运行,所有现有应用程序也将在浅色模式下运行.当满足两个条件时,在 macOS Mojave 上启动的应用程序将在黑暗模式下运行:

To run any app in Dark Mode, you must to be running macOS Mojave 10.14 or greater. By default, all existing apps will run in Light Mode even if the system is configured to run in Dark Mode. An app that is launched on macOS Mojave will run in Dark Mode when two criteria are met:

系统认为该应用与暗模式兼容正在运行的应用程序的外观设置为暗水色应用程序与暗模式的兼容性由其构建所针对的 SDK 和 NSRequiresAquaSystemAppearance" Info.plist 键的值的组合决定.如果您的应用是针对 10.14 SDK 或更高版本构建的,则除非将密钥设置为 YES,否则它将被视为兼容.如果您的应用是针对 10.13 SDK 或更早版本构建的,则除非将 Info.plist 键设置为 NO,否则它会被视为不兼容.

The system considers the app to be compatible with Dark Mode The running application’s appearance is set to Dark Aqua An app’s compatibility with Dark Mode is determined by a combination of the SDK it was built against, and the value of the "NSRequiresAquaSystemAppearance" Info.plist key. If your app is built against the 10.14 SDK or later, it will be considered compatible unless the key is set to YES. If your app is built against the 10.13 SDK or earlier, it is considered incompatible unless the Info.plist key is set to NO.

这篇关于弹出窗口中的 NSScrollView 在 MacOS Mojave 下变得透明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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