關於 UITableViewCell 的 indentationLevel

UITableViewCelltextLabel是有一個默認左邊距爲10px的。實際上,這是由indentationLevelindentationWidth 控制的緣故。indentationLevel 默認爲0,indentationWidth 默認爲10。
現在重新對這兩個屬性賦值。
cell.indentationLevel = 2;
cell.indentationWidth = 50;
運行之後,如下圖。cell 的縮進量明顯變大了。
縮進量 = indentationLevel * indentationWidth。值得注意的是,當indentationLevel = 0時,無論indentationWidth設爲多少,最後縮進量都爲10。
但是對於自定義cell來說,indentationLevel 並不能起到縮進效果。如下圖。要解決這個問題的話,可能只能通過改變約束來達到目的。
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章