iOS TableViewCell自定义分割线
2014-12-01 15:08
507 查看
http://www.software8.co/caozuoxt/ios/2491.html
产品设计的要求cell的分割线长度不用是整个屏幕宽,并且设计要求分割线为2px(两条),上下不同色。
实现如下:
UITableView中将分割线样式改为None
Java代码:
tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
自定义UITableViewCell中复写- (void)drawRect:(CGRect)rect方法
Java代码:
- (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));
}
产品设计的要求cell的分割线长度不用是整个屏幕宽,并且设计要求分割线为2px(两条),上下不同色。
实现如下:
UITableView中将分割线样式改为None
Java代码:
tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
自定义UITableViewCell中复写- (void)drawRect:(CGRect)rect方法
Java代码:
- (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));
}
相关文章推荐
- iOS开发笔记--cell最右边显示箭头,字符,自定义分割线
- iOS tableViewCell plane格式下,接近section边缘不显示分割线却被复用解决办法 分类: ios技术 2015-06-12 16:19 136人阅读 评论(0) 收藏
- iOS-swift-tableview隐藏多余的cell分割线
- iOS中 自定义cell分割线/分割线偏移 韩俊强的博客
- TableViewCell自定义分割线
- iOS开发技巧-tableView去掉多余的空行分割线,自定义Cell分割线
- TableViewCell自定义分割线
- iOS-UITableView 右侧箭头+取消分割线+取消选中样式+自定义分割线(原生和自定义cell)
- ios开发技巧之tableView去掉多余的空行分割线 自定义cell分割线
- iOS-解决自定义cell.selectedBackgroundView 遮挡分割线问题
- TableView 去掉多余行数、IOS最后一行Cell系统分割线顶头
- iOS开发之----去除tableViewCell分割线的左边间隙,将分割线填满
- iOS tableViewCell plane格式下,接近section边缘不显示分割线却被复用解决办法
- iOS开发技巧-tableView去掉多余的空行分割线,自定义Cell分割线
- TableViewCell自定义分割线
- iOS - TableViewCell分割线 --By吴帮雷
- ios tableviewcell分割线左边有空白
- iOS tableViewCell plane格式下,接近section边缘不显示分割线却被复用解决办法
- iOS-OC-UITableViewCell分割线自定义
- iOS开发笔记--cell最右边显示箭头,字符,自定义分割线