本篇向大家介紹UITalbeView的內容,內邊距,偏移量是什么,以及各種呈現的情況.
一、作為TableView的內容(content)由如下部分組成:
1.cell
2.tableHeaderView\tableFooterView
3.sectionHeader\sectionFooter
二、作為TableView的內容包含著如下屬性:
contentSize.height:所有內容的總高度
contentInset:在內容周圍額外增加的間距(內邊距),始終粘著內容
contentOffset:內容距離frame矩形框,偏移了多少
frame:是以父控件內容的左上角為坐標原點{0,0}
bounds:是以自己內容的左上角為坐標原點{0,0}
三、UITableView的各種展現形式的情況說明:
1. tableView在沒有Cell,沒有ContentInset, 沒有header和footer的情況下:
2. tableView在沒有cell, 沒有contentInset, 而有header和footer的情況下, ?(注意此時的內容為tableHeaderView + tableFooterView) ?:
3.tableView在有cell, 沒有contentInset, 沒有header和footer的情況下 (此時內容為整個cell):
4. tableView在有cell, 沒有contentInset, 有header和footer的情況下 (此時內容為header + cell + footer) :
5. tableView在有cell, 有contentInset, 有header和footer的情況下 (此時的內容為 header + cell + footer):
6. tableView在有cell, 沒有contentInset, 沒有header和footer, 但是有額外子控件的情況下 (此時的內容依然為整個cell):
7. tableView在有cell, 有contentInset, 沒有header 和footer的情況下 (內容依然為整個cell):
另外TableView的contentOffset指的是, 內容(content)與UITableView的偏移量. 假如內容向上偏離TableView, 那么?contentOffset.y 的值為正數, 反之為負數; 而內容向左偏離TableView, 那么contentOffset.x 的值為正數, 反之為負數.
希望大家對tableView的這些重要屬性掌握屬性, 千萬不要混淆之間的關系,謝謝!