简体   繁体   中英

NSOutlineView in NSPopover not readable in OSX 10.10 Yosemite

I have a NSPopover containing a NSOutlineView ( source list ) that is displayed over a usually dark background (but it's not always dark). The NSOutlineView has a transparent background to blend nicely with the NSPopover view. This looked great in OS X 10.9 but in 10.10 the system changes the text color in the NSOutlineView based on the background. The result is that the text becomes completely gray and unreadable in some cases:

在此输入图像描述

If I change the popover to be HUD style it is more readable:

在此输入图像描述

However, in this case, it becomes problematic with lighter backgrounds (the top).

Is there any way to control the text color in the NSOutlineView so that the color stays the same no matter the background? I have tried setting the color of the text cell to black instead of the system colors but it does not help.

Also, can I control/remove the transparency of the NSPopover ? I have read that NSPopover makes use of NSVisualEffectView , which has some appearance controls, but I don't know how to access it from NSPopover.

For aesthetic reasons I do not want to put the NSOutlineView under a solid background view. In this case there will be a ugly mismatch in color between the popover background and its arrow.

EDIT:

I was able to remove the transparency using the following code:

NSView *popoverView = popover.contentViewController.view.superview;
popoverView.appearance = [NSAppearance appearanceNamed:NSAppearanceNameAqua];

It works but feels like a ugly hack. I welcome better suggestions.

EDIT2:

This is what it looks like with the aqua style. No transparency and black text.

在此输入图像描述

将模式设置为除源列表之外的其他内容,您应该获得10.10之前的样式,即没有半透明效果。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM