1. 延长分割线
- (void)viewDidLayoutSubviews {
if ([self.tableView respondsToSelector:@selector(setSeparatorInset:)]) {
[self.tableView setSeparatorInset:UIEdgeInsetsZero];
}
if ([self.tableView respondsToSelector:@selector(setLayoutMargins:)]) {
[self.tableView setLayoutMargins:UIEdgeInsetsZero];
}
}
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
if ([cell respondsToSelector:@selector(setSeparatorInset:)]) {
[cell setSeparatorInset:UIEdgeInsetsZero];
}
if ([cell respondsToSelector:@selector(setLayoutMargins:)]) {
[cell setLayoutMargins:UIEdgeInsetsZero];
}
}
2. 不显示没内容的 Cell
self.tableView.tableFooterView = [[UIView alloc] init];
3. 修改 Cell 小对勾的颜色
self.tableView.tintColor = [UIColor redColor];
4. 去掉 SectionHeaderView 的悬浮效果
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
return 60.0;
}
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
// UITableViewStylePlain 样式下,去掉 SectionHeaderView 的悬浮效果
if (scrollView == self.tableView) {
CGFloat sectionHeaderHeight = 60.0;
if (scrollView.contentOffset.y<=sectionHeaderHeight && scrollView.contentOffset.y>=0) {
scrollView.contentInset = UIEdgeInsetsMake(-scrollView.contentOffset.y, 0, 0, 0);
} else if (scrollView.contentOffset.y>=sectionHeaderHeight) {
scrollView.contentInset = UIEdgeInsetsMake(-sectionHeaderHeight, 0, 0, 0);
}
}
}
5. 滚动条偏移
self.tableView.scrollIndicatorInsets = UIEdgeInsetsMake(0, 0, 49, 0);
6. 没有置顶
if ([self respondsToSelector:@selector(automaticallyAdjustsScrollViewInsets)] {
self.automaticallyAdjustsScrollViewInsets = NO;
}
7. 拖动时收起键盘
self.tableView.keyboardDismissMode = UIScrollViewKeyboardDismissModeOnDrag;
8. 滑动增加 Cell 动效
// 实际项目中不推荐使用,为了一点点炫,而增加卡顿不值得。
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
cell.alpha = 0.5;
CGAffineTransform transformScale = CGAffineTransformMakeScale(0.3, 0.8);
CGAffineTransform transformTranslate = CGAffineTransformMakeTranslation(0.5, 0.6);
cell.transform = CGAffineTransformConcat(transformScale, transformTranslate);
[tableView bringSubviewToFront:cell];
[UIView animateWithDuration:0.5f
delay:0
options:UIViewAnimationOptionAllowUserInteraction
animations:^{
cell.alpha = 1;
//清空 transform
cell.transform = CGAffineTransformIdentity;
}
completion:nil];
}