码迷,mamicode.com
首页 > 其他好文 > 详细

UITableViewCell绘制分割线

时间:2015-07-04 11:22:46      阅读:251      评论:0      收藏:0      [点我收藏+]

标签:

第一步:

//UITableView去掉自带系统的分割线

_tableView.separatorStyle = UITableViewCellSeparatorStyleNone;


第二步:

//在自定义的UITableViewCell里重写drawRect:方法

#pragma mark - 绘制Cell分割线

- (void)drawRect:(CGRect)rect {

    

    CGContextRef context = UIGraphicsGetCurrentContext();

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

    CGContextFillRect(context, rect);

    

    //上分割线,

    CGContextSetStrokeColorWithColor(context, [UIColor colorWithRed:198/255.0 green:198/255.0 blue:198/255.0 alpha:1].CGColor);

    CGContextStrokeRect(context, CGRectMake(0, 0, rect.size.width, 1));

    

    //下分割线

    CGContextSetStrokeColorWithColor(context, [UIColor colorWithRed:198/255.0 green:198/255.0 blue:198/255.0 alpha:1].CGColor);

    CGContextStrokeRect(context, CGRectMake(0, rect.size.height, rect.size.width, 1));

    

}


UITableViewCell绘制分割线

标签:

原文地址:http://my.oschina.net/u/2360693/blog/474453

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!