從 iOS 7 開始,UITableViewCell 使用 layoutMargins,直接改 frame 不一定能調整分割線位置。
可在 willDisplayCell 中將 cell 的 layoutMargins 設為 UIEdgeInsetsZero,並關閉 preservesSuperviewLayoutMargins。
if ([cell respondsToSelector:@selector(setLayoutMargins:)]) {
[cell setLayoutMargins:UIEdgeInsetsZero];
}
if ([cell respondsToSelector:@selector(setPreservesSuperviewLayoutMargins:)]) {
[cell setPreservesSuperviewLayoutMargins:NO];
}
可用 willDisplayHeaderView 調整 tintColor 與 textLabel 的 textColor。
最簡單方式是把 tableFooterView 設為空白 UIView,讓沒有資料的儲存格不顯示線。
self.tableView.tableFooterView = [[UIView alloc] init];