Reputation: 4248
I'm setting UITableView
separator color this way:
- (void)viewDidLoad
{
[super viewDidLoad];
self.tableView.separatorColor = [UIColor colorWithRed:1.0f green:1.0f blue:1.0f alpha:0.1f];
}
And SOMETIMES on iOS7 my table view separators look different (cells with data and empty cells separators have different alpha I guess), look at attached image:
How can I solve this issue?
Upvotes: 2
Views: 6362
Reputation: 3457
You can set it programatically:
- (void)viewDidLoad {
[super viewDidLoad];
[[UITableView appearance] setSeparatorColor:[UIColor redColor]];
}
Upvotes: 1
Reputation: 7474
You can achieve this visually in storyboard or nib/xib
Put UIImageView at bottom edge of cell and you can set image as per your requirement
STEP 1: Set divider as per image
STEP 2: Set Separator style to none
Upvotes: 2
Reputation: 47059
If you want to remove all cell's separator which has empty content then use following line of code.
self.tableView.tableFooterView = [[UIView alloc] init];
in viewDidLoad
method.
Other wise set self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
and set your custom UIImage
for separator.
EX:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSString *CellIdentifier = @"cell"; //[NSString stringWithFormat:@"S%1dR%1d", indexPath.section, indexPath.row];
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if(cell == nil)
{
cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
.
. // your other code.
.
UIImageView *imgLine = [[UIImageView alloc] init];
imgLine.tag = 101;
[cell.contentView addSubview: imgLine];
}
.
. // your other code.
.
UIImageView *imgLine = (UIImageView *) [cell.contentView viewWithTag:101];
imgLine.frame = CGRectMake(5, 69, 310, 1);
imgLine.image = [UIImage imageNamed:@"queTblLine.png"];
return cell;
}
And don't forget to set self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
EDITE : Not sure but might be helpful in your case:
set self.tableView.separatorInset = UIEdgeInsetsZero;
Upvotes: 3
Reputation: 425
Swap the order of the two statements. Set the color first, then the inset:
self.tableView.separatorColor = [UIColor redColor];
self.tableView.separatorInset = UIEdgeInsetsZero;
Upvotes: 2