产品设计的要求cell的分割线长度不用是整个屏幕宽,并且设计要求分割线为2px(两条),上下不同色。
实现如下:
UITableView中将分割线样式改为None
tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
自定义UITableViewCell中复写- (void)drawRect:(CGRect)rect方法
- (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 TableViewCell收缩、伸缩、缩放功能
在XCode12中实现自定义TableViewCell微博事例,包含图片资源及plist数据
iOS TableViewCell 组件,选择单元格,然后显示一个下拉的详情信息。
拖拽排序: 今日头条,网易新闻,订阅频道的拖拽排序功能简单实现。 支持标签长度不同。 [gitHub源码地址] (https://github.com/HelloYeah/DraggingSort)
tableViewCell图片lazyload 图片延迟加载
用于tableViewCell 和 collectionViewCell 的移动 如发现问题请发邮件至ranheran@sohu.com,我会尽快修正
IOS源码——自定义UITableViewCell。实现各种样式的表格输入界面.zip
用Swift实现的简单自定义TableViewCell
在UITableViewCell里面加入自定义控件,本文以Lable为例,给读者提供一种动态控制Cell高度的思想,由这种思想出发,读者可以以此来动态控制cell的高度。
iOS 自定义UITableViewCell,iOS 自定义表视图 博客地址:http://blog.csdn.net/yang8456211
UItableview cell (自定义)增假,删除 移动
在github中有许多大牛封装好的第三发类库,其中有个自适应cell高度的类库 ...model类 commentsModel #import JSONModel.h #import getCommentData.h @interface commentsModel : JSONModel @property(nonatomic,copy)...
用Swift语言实现了自定义tableViewCell。 包含了一个TableViewCell的基类以及自定义的tableViewCell类的实现和调用。
swift简单的自定义tableViewCell实现
源码MSCellAccessory,自定义 UITableViewCell 的 AccessoryType。所谓AccessoryType,就是用于在列表cell的尾端显示一个小按钮,用于提示此cell的一些功能,比如DETAIL DISCLOSURE,DISCLOSURE INDICATOR,...
自定义符合要求饿到cell,让你的tableview更加适用
分割线的位置就是指分割线相对于tableViewCell.如果我们要根据要求调节其位置,那么在iOS7.0版本以后,提供了一个方法如下: if ([self.tableView respondsToSelector:@selector(setSeparatorInset:)]) { [self....
博客中的IOS TableView的Cell高度自适应,UILabel自动换行适应 的项目源码
tableviewcell的移动、删除、添加