UITableView使用记录

目录
1 UITableView的type
1.1 UITableView的类型(type)
public enum Style : Int, @unchecked Sendable {
case plain = 0 // 通用类
case grouped = 1 // 分组模式
@available(iOS 13.0, *)
case insetGrouped = 2 // iOS13以后支持的API,给组加圆角,效果如下
}

insetGrouped
1.2 iOS15系统之后type为grouped
时,头部有间距
if #available(iOS 15.0, *) {
tableView.sectionHeaderTopPadding = 0
}
if (@available(iOS 15.0, *)) {
_tableView.sectionHeaderTopPadding = 0;
}
1.3 type为grouped
时,组间距问题
func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
return 0
}
func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
return UIView()
}
1.4 去除诡异动画
[UIView setAnimationsEnabled:false];
[CATransaction begin];
[CATransaction setCompletionBlock:^{
[UIView setAnimationsEnabled:true];
}];
[self.tableView beginUpdates];
[self.tableView insertRowsAtIndexPaths:addIndexPathes
withRowAnimation:UITableViewRowAnimationNone];
[self.tableView endUpdates];
[CATransaction commit];