Friday, June 7, 2013

UITableView setSeparatorColor example in Objective C (iOS).


UITableView setSeparatorColor

The color of separator rows in the table view.

@property(nonatomic, retain) UIColor *separatorColor

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

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

Example of [UITableView setSeparatorColor].
- (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 setSeparatorColor example.
UITableView * tempTable = [[UITableView alloc] init];

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

End of UITableView setSeparatorColor example article.