1。UITableView 隐藏多余的分隔线
+(void)setExtraCellLineHidden:(UITableView*)tableView{
UIView *view = [[UIView alloc] init];
view.backgroundColor = [UIColor clearColor];
[tableView setTableFooterView:view];
[view release];
}
2。UITableView 定义选中cell的背景颜色
cell.selectedBackgroundView = [[[UIView alloc] initWithFrame:cell.frame] autorelease];
cell.selectedBackgroundView.backgroundColor = TABLEVIEW_SELECTED_COLOR;
清除选中颜色就不用说了
今天做项目时突然发现取消选中状态后,tableView 复用时选中状态又出现了,原来的代码
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
[cell setSelected:NO animated:NO];
如果有这样的问题可以换uitableview 的方法
[tableView deselectRowAtIndexPath:indexPath animated:NO];
3.去掉UItableView header 粘连效果(网友写的,很好用)
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
if (scrollView == atWhoTableView)
{
CGFloat sectionHeaderHeight = 24; //sectionHeaderHeight
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);
}
}
}