#iOS知识小集#「 关于 UITableViewCell 的 indentationLevel 」
UITableViewCell 的 textLabel 是有一个默认左边距为10px的。实际上,这是由indentationLevel 和 indentationWidth 控制的缘故。indentationLevel 默认为0,indentationWidth 默认为10。
现在重新对这两个属性赋值。
cell.indentationLevel = 2;
cell.indentationWidth = 50;
运行之后,如图一。cell 的缩进量明显变大了。
缩进量 = indentationLevel * indentationWidth。值得注意的是,当indentationLevel = 0时,无论indentationWidth设为多少,最后缩进量都为10。
但是对于自定义cell来说,indentationLevel 并不能起到缩进效果。如图二。要解决这个问题的话,可能只能通过改变约束来达到目的。如果有更好的解决方案,欢迎交流。
UITableViewCell 的 textLabel 是有一个默认左边距为10px的。实际上,这是由indentationLevel 和 indentationWidth 控制的缘故。indentationLevel 默认为0,indentationWidth 默认为10。
现在重新对这两个属性赋值。
cell.indentationLevel = 2;
cell.indentationWidth = 50;
运行之后,如图一。cell 的缩进量明显变大了。
缩进量 = indentationLevel * indentationWidth。值得注意的是,当indentationLevel = 0时,无论indentationWidth设为多少,最后缩进量都为10。
但是对于自定义cell来说,indentationLevel 并不能起到缩进效果。如图二。要解决这个问题的话,可能只能通过改变约束来达到目的。如果有更好的解决方案,欢迎交流。
展开
评论
1