Re: Is it possible to set an NSTableView cell background color?
Re: Is it possible to set an NSTableView cell background color?
- Subject: Re: Is it possible to set an NSTableView cell background color?
- From: Quincey Morris <email@hidden>
- Date: Wed, 22 Feb 2017 19:30:45 -0800
- Feedback-id: 167118m:167118agYYG0F:167118s-nzWn5HNh:SMTPCORP
On Feb 22, 2017, at 17:45 , David Delmonte <email@hidden> wrote:
>
> It's cell based!
In that case, you need to implement the delegate method "tableView(_:willDisplayCell:for:row:)”, which is called once for each cell that’s redrawn.
In your method, you need to verify that the cell is of the type you expect (a NSTextFieldCell, I’m guessing), cast it to the correct type, and then set its backgroundColor property. Note that NSCell does not itself have such a property, it’s only implemented by specific subclasses.
Alternatively, it is possible to prepare one cell per color at initialization, then supply the correctly colored cell at each row/column. This is slightly more efficient, because it doesn’t involve re-configuring the cell each time it’s used, but it’s a bit more code (also in the delegate).
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden