自定义cell上下分割线

Step1:

    menuTableView.separatorStyle = UITableViewCellSeparatorStyleNone;

 Step2: 重写此方法

  

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

  

原文地址:https://www.cnblogs.com/zylike/p/3994561.html