I have a table that separates its cells by alternating backgrounds colors (dark blue, light blue) so I want to g开发者_开发问答et rid of the separators. However, setting separator style to none, while it does seem to remove the separators, does not push the cells together (there is still a gap where the separator was and the background can be seen through it). I changed the separator color to the color of one of the cells, and it looks decent, but it makes every other cell look larger than the one before and after it. It's barely noticeable, but I'd still like to remedy it. How can I do this?
You can try adding a subview at the bottom of the cell with 1 px height and set the background color.
UITableViewCell * cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"] autorelease];
UIView * view = [[UIView alloc] init];
view.frame = CGRectMake(cell.frame.size.height,0,1,cell.frame.size.width);
view.autoresizingMask = UIViewAutoresizingFlexibleWidth;
[cell addSubview:view];
[view release];
And make the
cell.clipsToBounds = NO;
I have not tested it and I hope this work :-)
精彩评论