1.//
设置分割线有内容显示,无内容不显示
self.tableView.tableFooterView
= [[UIView
alloc]
init];
2.//设置分割线从头显示
// if ([self.tableView
respondsToSelector:@selector(setSeparatorInset:)]) {
// [self.tableView setSeparatorInset:UIEdgeInsetsZero];
// }
3.//设置分割线从10开始显示
self.tableView.separatorInset=UIEdgeInsetsMake(0,10,0,0);
一般TableView设置全屏分隔线有下面三种方法
1.自定义cell,手动添加分割线
隐藏自带的
tableView.separatorStyle =
UITableViewCellSeparatorStyleNone;
可以通过addSubview的方式添加一条分割线;也可以自绘分割线。
// 自绘分割线
- (void)drawRect:(CGRect)rect
{
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetFillColorWithColor(context, [UIColor whiteColor].CGColor);
CGContextFillRect(context, rect);
CGContextSetStrokeColorWithColor(context, [UIColor colorWithRed:0xE2/255.0f green:0xE2/255.0f blue:0xE2/255.0f alpha:1].CGColor);
CGContextStrokeRect(context, CGRectMake(0, rect.size.height - 1, rect.size.width, 1));
}
2.重写cell的setFrame方法,高度-1,露出背景色
- (void)setFrame:(CGRect)frame
{
frame.size.height -= 1;
// 给cellframe赋值
[super setFrame:frame];
}
取消系统的分割线
设置table