UITableViewCell笔记
2016-07-26 本文已影响297人
我是花老虎
- 默认的四种cell的类型
默认CellStyle
原网站
还有这个带图的
据我自己试验,只有value2不自带imageview -
不同的accessoryType
accessoryType效果
可以看到,一个tabelviewcell的contentview被缩短了。右边是显示附件的view。
视图层级
- 设置
accessoryView
contentView也变短了,此时设置的accessoryType没用了。accessoryView
的大小也会影响到contentview的大小
accessoryView
cell的组成
- 设置缩进
-
indentationLevel
和indentationWidth
indentationLevel
和indentationWidth
乘积是缩进的距离。indentationWidth
默认是10point。
if indexPath.row == 0 {
cell?.indentationLevel = 2;
}
else if indexPath.row == 1
{
cell?.indentationLevel = 2;
cell?.indentationWidth = 20;
}
![](https://img.haomeiwen.com/i1925101/d81a79dca4aa06e1.png)
- 设置分隔线的范围
separatorInset
默认分割线距离左边最短是15point。可以通过这个方法来设置。但是好像改变了这个值,系统默认的textlabel什么的也会移动。
cell?.separatorInset = UIEdgeInsetsMake(0, 0, 0, 0)
![](https://img.haomeiwen.com/i1925101/c56c3c1467a86998.png)
cell?.separatorInset = UIEdgeInsetsMake(0, 30, 0, 40)
![](https://img.haomeiwen.com/i1925101/d6753ced95ce6136.png)