自定义的分割线

来源:互联网 发布:入侵棋牌游戏数据库 编辑:程序博客网 时间:2024/04/29 15:40

这是自定义的cell里面要添加的方法,前提是写了去掉系统的分割线

tableView.separatorStyle = UITableViewCellSeparatorStyleNone; 

//自定义的分割线

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