• 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: NSTableView changing background
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSTableView changing background


  • Subject: Re: NSTableView changing background
  • From: James Chen <email@hidden>
  • Date: Fri, 19 Dec 2003 14:15:27 +0800

I resolved this by overriding - (void)drawRow:(int)rowIndex clipRect:(NSRect)clipRect of NSTableView
- (void)drawRow:(int)rowIndex clipRect:(NSRect)clipRect
{
NSRect cellRect = [self rectOfRow:rowIndex];
if (rowIndex % 2 == 1 && ![self isRowSelected:rowIndex]) {
NSColor* rowColor = [NSColor colorWithCalibratedRed:0.0 green:0.5 blue:1.0 alpha:0.3];
[rowColor set];
[NSBezierPath fillRect:cellRect];
}
[super drawRow:rowIndex clipRect:clipRect];
}
Hope this is what you want,
Jam
------------------------------------
Ulead Systems Inc.
James Chen
Software Engineer
Image Div.
------------------------------------
On Dec 19, 2003, at 11:41 AM, Jay Rimalrick wrote:

I am trying to change the color of an entire row of an NSTableView. I am using the delegate shown below to change the cell colors based on the row number. However, there are spaces between the cells that show the background color ... is there any way to color in a whole row?

- (void)tableView: (NSTableView *)aTableView willDisplayCell:(id)aCell
forTableColumn:(NSTableColumn *)TC row:(int)row
{
if ( (row % 2) == 0)
{
[aCell setDrawsBackground: YES];
[aCell setBackgroundColor:
[NSColor colorWithCalibratedRed: 0.9 green: 0.9 blue:1 alpha:
1.0]];
}
}




________________________________________________________________
Sent via the WebMail system at 1st.net
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >NSTableView changing background (From: "Jay Rimalrick" <email@hidden>)

  • Prev by Date: Initialdefaultsvector
  • Next by Date: can no longer build - many warnings, internal bus error
  • Previous by thread: NSTableView changing background
  • Next by thread: NSButtonCell problem -- Title ends up at bottom
  • Index(es):
    • Date
    • Thread