1

If I use following line in iOS 5 + its working perfectly.

cell.backgroundColor = [UIColor colorWithWhite:0.0 alpha:0.2];

But this is not working in iOS 4. I also tried following but its not working.

- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
    cell.backgroundColor = [UIColor colorWithWhite:0.0 alpha:0.2];
}

- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
    for (UIView *subview in [cell.contentView subviews]) {
        subview.backgroundColor = [UIColor colorWithWhite:0.0 alpha:0.2];
    }
}

If I set color in willDisplayCell , its showing me black background for cell. How can I set background cell color which will work in both iOS 4 & iOS 5.

Any knid of help is appreciated. Thanks

iOSAppDev
  • 2,755
  • 4
  • 39
  • 77
  • Please refer this link for setting cell background image http://stackoverflow.com/questions/9715572/tableview-how-change-the-cell-default-blue-color/9715778#9715778 – iNeal Apr 18 '12 at 13:10
  • Thanks for the link. But my problem solved already. Problem is with line [UIColor colorWithWhite:0.0 alpha:0.2]; It should be [UIColor colorWithWhite:1.0 alpha:0.2]; – iOSAppDev Apr 19 '12 at 05:46

0 Answers0