UITableview 分组高度设置为0.01会出现一根线
在之前,当tableView.style = UITableViewStyleGrouped的时候,设置sectionHeader和sectionFooter的高度为0的时候,往往设置0不管用<iOS10>,会设置个0.01。为了封装方便,可能有的时候当tableView.style = UITableViewStylePlain的时候,也会这么干。
这样就会使得tableView.style = UITableViewStyleGrouped/UITableViewStylePlain的时候让sectionHeader和sectionFooter的高度看不到了
但是在iOS14,就会出现上面说的那种情况,当然了tableView.style = UITableViewStyleGrouped不受影响
适配方案:
1、当tableView.style = UITableViewStylePlain
iOS10~iOS14通用
都 return 0;
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section { return 0;}
2、如果当前封装的tableView两种类型都有,那么进行相关的判断
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section { if (tableView.style == UITableViewStyleGrouped) { return 0.01; } return 0; }
作者:從此珍惜
链接:https://www.jianshu.com/p/c6f1008770e3
来源:简书
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。