Transparent Background NSTextfield NSPopover

Disclaimer: This question is an extension of this question.

I am trying to populate a table in NSPopover. (As seen in the picture)


Problem:
I can not make a transparent background for NSTextField.

Strange, it works fine if a view is attached to NSWindow


(The names in the left window have a transparent background, but the same look as in NSPopover does not show a transparent background for the NSText field.) enter image description here

Is this a bug in NSPopover or am I doing something wrong?


This is my code for creating table cells

func tableView(tableView: NSTableView, viewForTableColumn tableColumn: NSTableColumn?, row: Int) -> NSView? { var cell = NSTableCellView(frame: NSMakeRect(0, 0, 100, 40)) var textField = NSTextField(frame: NSMakeRect(0, 0, 50, 20)) // **For transparency** textField.stringValue = nameList[row] textField.bezeled = false textField.editable = false textField.drawsBackground = false cell.addSubview(textField) return cell } 
+7
cocoa nstableview macos nspopover
source share
1 answer

This is a problem with the text field being rendered in a bright way, which leads to the fact that the white background in the form of a table around it will also be rendered. This vibration causes the plusL mixing mode, therefore it becomes invisible).

This only happens in a popover because it is a vibrant context and is set by default with NSAppearanceNameVibrantLight .

Sessions 209 and 220 from WWDC2014 discuss a bit more about the dynamics and release notes for 10.10 in NSVisualEffectView / vibrancy.


To get around this, you can set the appearance of the table view to the appearance of NSAppearanceNameAqua .

+10
source share

All Articles