天天看点

重绘UITableViewCell分割线

  有时候项目有改动UITableViewCell分割线的需求,重写drawRect方法 可实现各类分割线

- (void)drawRect:(CGRect)rect {

    CGContextRef context = UIGraphicsGetCurrentContext();

    CGContextSetFillColorWithColor(context, [UIColor clearColor].CGColor); CGContextFillRect(context, rect);

    //分割线颜色 

    CGContextSetStrokeColorWithColor(context, [UIColor colorWithWhite:0.902 alpha:1.000].CGColor);

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

}