美文网首页
TableViewCell自定义分割线

TableViewCell自定义分割线

作者: 张群 | 来源:发表于2015-04-22 22:34 被阅读2287次

UITableView中将分割线样式改为None

tableView.separatorStyle = UITableViewCellSeparatorStyleNone;

自定义UITableViewCell中复写- (void)drawRect:(CGRect)rect方法

- (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));

}

相关文章

网友评论

      本文标题:TableViewCell自定义分割线

      本文链接:https://www.haomeiwen.com/subject/ouupxttx.html