I use UITableView's
cellForRowAtIndexPath
to display the data (NSString*
) by assigning cell.textLabel.text = [li开发者_运维知识库st objectAtIndex:indexPath.row];
Everything is fine but I need to color certain lines, so I use cell.textLabel.backgroundColor
and cell.textLabel.textColor
. The colored lines look a bit ugly - they have blank space at the beginning and at the end (both are roughly 1 char wide). Maybe these are reserved for scrolling marker (up/down)? Is there a way to use the whole width of the cell while keeping scrolling ability up? Any special style or flag? Thanks. Victor
The label does not fill the entire cell, so setting its background colour will not cover everything.
Set the cell's background colour instead, but this has to be done in the willDisplayCell: delegate method, not cellForRowAtIndexPath: (see the docs for details: http://developer.apple.com/library/ios/DOCUMENTATION/UIKit/Reference/UITableViewCell_Class/Reference/Reference.html#//apple_ref/occ/cl/UITableViewCell
精彩评论