uitableview指定的分割线的颜色
来源:互联网 发布:磨刀器哪个牌子好 知乎 编辑:程序博客网 时间:2024/05/22 05:25
UITableView的分割线(separator)是私有类,应该是无法获取的。
不过你可以通过tableView的属性修改它:
1
2
3
4
5
6
7
8
9
UITableView * tableView = [[UITableView alloc] initWithFrame:CGRectMake(20, 20, 400, 300) style:UITableViewStylePlain];
tableView.separatorColor = [UIColor redColor];
tableView.separatorInset = UIEdgeInsetsMake(0,80, 0, 80);
// 设置端距,这里表示separator离左边和右边均80像素
tableView.separatorStyle = UITableViewCellSeparatorStyleSingleLine;
tableView.dataSource = self;
如此设置后的tableView是这样的:(左右空出了80像素)
如果你想设置单个分割线的颜色,那就自己画分割线吧。你可以用coreGraphics,也可以用UIView,这里用UIView来画:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
UITableView * tableView = [[UITableView alloc] initWithFrame:CGRectMake(20, 20, 400, 300) style:UITableViewStylePlain];
tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
// 这样就不会显示自带的分割线
tableView.dataSource = self;
for
(
int
i = 0; i < 8; i++) {
UIView * separator = [[UIView alloc] initWithFrame:CGRectMake(10, (i+1) * 40
/* i乘以高度*/
, 380, 1)];
separator.backgroundColor = [UIColor colorWithRed:0.03 * i green:0.05*i blue:0.1*i alpha:1];
[tableView addSubview:separator];
}
[self addSubview:tableView];
效果:
滚动正常
当然,为了和谐,你应该把自定义的separator的间隔和cell的高度设为一致。
阅读全文
0 0
- uitableview指定的分割线的颜色
- UITableView指定分割线 并且设置颜色
- UITableView不弹动,分割线颜色,cell的高度
- 设置UITableView分割线的颜色和位置
- UITableView 分割线的缩进
- 关于UITableView的分割线
- UITableView 分割线设置 (去掉底部多余的分割线)
- UITableView的分割线从最左侧开始, 右箭头,分割线颜色; UITableViewCell中ImageView位置大小控制
- UITableView的分割线从最左侧开始, 右箭头,分割线颜色; UITableViewCell中ImageView位置大小控制
- iOS小技巧-UITableView去除底部多余的分割线方法以及设置分割线风格和颜色
- UITableView的cell的分割线位置
- UITableView的分割线的应用
- UITableView的分割线长短的控制
- UITableView 的多余分割线的去除
- UITableView隐藏多余的分割线
- 隐藏UITableView多余的分割线
- 清除UITableView底部多余的分割线
- 隐藏UITableView多余的分割线
- Entity Framework With Oracle
- jQuery源码分析
- tensorflow中slim模块api介绍
- Vue数组对象深拷贝
- 布尔类型
- uitableview指定的分割线的颜色
- 设计模式(20)--观察者模式
- Java虚拟机规范 JavaSE8版读书笔记
- loadrunner 测试webservice 通过soap_reuest 2
- string(json)转map
- CentOS 下安装 Nginx
- aliyun网站部署
- composer
- iis部署需要看视频