您的位置:首页 > 其它

自定义tableview分割线

2016-05-17 17:52 387 查看
UITableView中将分割线样式改为None

mainTableView.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
purpleColor].CGColor);

CGContextStrokeRect(context,
CGRectMake(5, -1, rect.size.width -
10, 1));

//下分割线

CGContextSetStrokeColorWithColor(context, [UIColor
orangeColor].CGColor);

CGContextStrokeRect(context,
CGRectMake(5, rect.size.height, rect.size.width -
10, 1));

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: