• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Is it possible to set an NSTableView cell background color?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >Is it possible to set an NSTableView cell background color? (From: David Delmonte <email@hidden>)
 >Re: Is it possible to set an NSTableView cell background color? (From: Quincey Morris <email@hidden>)
 >Re: Is it possible to set an NSTableView cell background color? (From: David Delmonte <email@hidden>)

  • Prev by Date: Re: Is it possible to set an NSTableView cell background color?
  • Next by Date: I think I screwed up Core Data multi-threading rules.
  • Previous by thread: Re: Is it possible to set an NSTableView cell background color?
  • Next by thread: I think I screwed up Core Data multi-threading rules.
  • Index(es):
    • Date
    • Thread