天天看點

重繪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));

}