UIView_TableView

来源:互联网 发布:知乎 电脑版 编辑:程序博客网 时间:2024/05/22 04:42


自定义tableview的cell分割线

1.把自带的cell分割线隐藏

_tableView.separatorStyle =   UITableViewCellSeparatorStyleNone;

2.重写- (void)drawRect:(CGRect)rect方法

- (void)drawRect:(CGRect)rect{    CGContextRef context = UIGraphicsGetCurrentContext();        CGContextSetFillColorWithColor(context, [UIColor clearColor].CGColor);    CGContextFillRect(context, rect);        //上分割线,    CGContextSetStrokeColorWithColor(context, RGBCOLOR(229, 229, 229).CGColor);    CGContextStrokeRect(context, CGRectMake(5, -1, rect.size.width, 1));        //下分割线    CGContextSetStrokeColorWithColor(context, RGBCOLOR(229, 229, 229).CGColor);    CGContextStrokeRect(context, CGRectMake(5, rect.size.height, rect.size.width, 1));}


0 0
原创粉丝点击