千万别小看UI中得线,否则你的设计师和测试组会无休止地来找你的!!(如果是美女还好,如果是恐龙。。。。)

在开发中运用最多的是什么,对,表格--TableView,之所以称作表格,是因为他天生带有分割线。

首先系统带的有如下类型:

typedef NS_ENUM(NSInteger, UITableViewCellSeparatorStyle) {
UITableViewCellSeparatorStyleNone,
UITableViewCellSeparatorStyleSingleLine,
UITableViewCellSeparatorStyleSingleLineEtched // This separator style is only supported for grouped style table views currently
};

有时你要短点的,如同这样:

那你可以这样:

 if ([_pinglunTableView respondsToSelector:@selector(setSeparatorInset:)]) {
UIEdgeInsets insets=UIEdgeInsetsMake(0, 53, 0, 0);
[_pinglunTableView setSeparatorInset:insets];
}

也可以完全自己定义自己想要的分割线,但意味着你要自定义 TableViewCell,然后在自定义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);
CGContextSetStrokeColorWithColor(context, [UIColor colorWithHexString:@"ffffff"].CGColor);
CGContextSetStrokeColorWithColor(context, [UIColor colorWithHexString:@"e2e2e2"].CGColor);
CGContextStrokeRect(context, CGRectMake(5, rect.size.height, rect.size.width - 10, 1));//下分割线
CGContextSetStrokeColorWithColor(context, [UIColor colorWithHexString:@"e2e2e2"].CGColor);
CGContextStrokeRect(context, CGRectMake(5, rect.size.height, rect.size.width - 10, 1));
}

如果要改变颜色,则利用类似[tableView setSeparatorColor:[UIColor redColor]];语句即可修改cell中间分割线的颜色。

如果UI给你一张图片,那么就可以这样:

方法一:
先设置cell separatorColor为clear,然后把图片做的分割线添加到自定义的custom cell上。

方法二:
在cell里添加一个像素的imageView后将图片载入进,之后设置tableView.separatorStyle = UITableViewCellSeparatorStyleNone

最新文章

  1. Oracle SQL Developer 连接 MySQL
  2. sed教程
  3. Not Hello World
  4. python numpy包
  5. Git本地提交到远程指定分支
  6. 多个mysql解决方法
  7. Report_客制化以PLSQL输出HTML标记实现WEB报表(案例)
  8. 【转】linux之e2label命令
  9. PSP编程初探 Hello World
  10. Cesium的api之关于viewer
  11. hdu1046
  12. 使用微软URLRewriter.dll的url实现任意后缀名重写
  13. css 行内元素设置宽高
  14. Alpha阶段Scrum Meeting合集(江山代有才人秃队)
  15. bootstrap-table前端修改后台传来的数据重新进行渲染
  16. Django Context对象 + 过滤器 + 标签
  17. DOM绑定事件
  18. Eclipse Unhandled event loop exception GC overhead limit exceeded
  19. Docker启动一个Centos镜像
  20. 解决iframe加载的内容有时显示有时不显示

热门文章

  1. xorm 条件查询时区的问题
  2. Red Scarf abc171_E
  3. django 修改模型中默认字段类型
  4. Ant 调用 Shell/CMD 命令
  5. PPT2010初识
  6. Elasticsearch安装与配置
  7. 使用.NET 6开发TodoList应用(25)——实现RefreshToken
  8. k8s中的nginx-ingress如何配置路径重定向
  9. Java实现抽奖模块的相关分享
  10. 【Java】eclipse中的JUnit单元测试