Friday, June 7, 2013

UITableView separatorColor example in Objective C (iOS).


UITableView separatorColor

The color of separator rows in the table view.

@property(nonatomic, retain) UIColor *separatorColor

Discussion of [UITableView separatorColor]
The default color is gray.

UITableView separatorColor example.
- (void)viewDidLoad
{
   [self.tableView setSeparatorColor:[UIColor myColor]];
}

Example of [UITableView separatorColor].
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
switch (indexPath.section) {
    case 0:
        tableView.separatorColor = nil;
        break;
    case 1:
        switch (indexPath.row) {
            case 0:
                tableView.separatorColor = nil;
                break;
            case 1:
                tableView.separatorColor = [UIColor clearColor];
                break;
            default:
                break;
        }
        break;
    default:
        break;
}

UITableView separatorColor example.
UITableView * tempTable = [[UITableView alloc] init];

[table setSeparatorColor:tempTable.separatorColor];
[table setSeparatorStyle:tempTable.separatorStyle];
table.backgroundView = tempTable.backgroundView;

End of UITableView separatorColor example article.