Note that there are some explanatory texts on larger screens.

plurals
  1. POUITableViewCell background color problem
    primarykey
    data
    text
    <p>I subclassed UITableViewCell to set a cell background color to a color I need:</p> <p>.h</p> <pre><code>@interface DataViewCustomCell : UITableViewCell { UIColor* cellColor; UIColor* standardColor; } - (void) setCellColor: (UIColor*)color; @end </code></pre> <p>.m</p> <pre><code>@implementation DataViewCustomCell - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; if (self) { // Initialization code } return self; } - (void) setCellColor: (UIColor*)color { cellColor = color; } - (void) spreadBackgroundColor: (UIView*)that withColor: (UIColor*)bkColor { NSEnumerator *enumerator = [that.subviews objectEnumerator]; id anObject; while (anObject = [enumerator nextObject]) { if([anObject isKindOfClass: [UIView class]]) { ((UIView*)anObject).backgroundColor = bkColor; [self spreadBackgroundColor:anObject withColor:bkColor]; } } } - (void) layoutSubviews { [super layoutSubviews]; // layouts the cell as UITableViewCellStyleValue2 would normally look like if(!self.selected &amp;&amp; NULL != cellColor) { [self spreadBackgroundColor:self withColor:cellColor]; } } - (void)dealloc { [super dealloc]; } @end </code></pre> <p>When I call setCellColor with the color I want, all goes well, but when I haven't found a way to set the original color back: when I set <code>[UIColor clearColor]</code> with UITableViewStylePlain style the results is not good-looking.</p> <p><img src="https://i.stack.imgur.com/GDnwA.png" alt="Wrong result"> </p> <p>How can I achieve a good result, without a missing cell separator line?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload