关于tableviewCell的一些小技巧

来源:互联网 发布:大众软件吧 编辑:程序博客网 时间:2024/05/01 15:33

设置cell的分割线颜色

[tableView setSeparatorColor:color];

设置cell分割线的长短

[tableViewsetSeparatorInset:UIEdgeInsetsMake(0,0,0,0)];

重写cell的分割线

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

设置cell的描边 (其实就是分组

除非需要设置每个section的header,不需要用代理去返回header的view,使用xib或SB布局时,设置style为Group就OK了。

0 0
原创粉丝点击