if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0) { [_tableView setLayoutMargins:UIEdgeInsetsZero]; } else if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0){ [_tableView setSeparatorInset:UIEdgeInsetsZero]; } - (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath{ if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0) { [cell setSeparatorInset:UIEdgeInsetsZero]; [cell setLayoutMargins:UIEdgeInsetsZero]; } else if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0){ [cell setSeparatorInset:UIEdgeInsetsZero]; } }
(1)隐藏
self.tableView.showsVerticalScrollIndicator = NO;
(2)修改颜色
self.tableView.indicatorStyle=UIScrollViewIndicatorStyleWhite;
_tableView.tableFooterView = [[[UIView alloc] initWithFrame:CGRectZero] autorelease];
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{ UIView *customView = [[[UIView alloc] initWithFrame:CGRectMake(10, 0, 300, 44)] autorelease]; UILabel *headerLabel = [[[UILabel alloc] initWithFrame:CGRectZero] autorelease]; headerLabel.backgroundColor = [UIColor clearColor]; headerLabel.textColor = [UIColor lightGrayColor]; headerLabel.font = [UIFont systemFontOfSize:14.0]; headerLabel.frame = CGRectMake(10, 0, 300, 44); if (section == 0) { headerLabel.text = NSLocalizedString(@"GroupName", @"群组名称"); } else if (section == 1){ headerLabel.text = NSLocalizedString(@"GroupDescription", @"群组公告(0~36)"); } [customView addSubview:headerLabel]; return customView; }
cell.contentView.clipsToBounds = YES; cell.clipsToBounds = YES;
我们在点击UITableView 的cell时,会出现阴影,如不做处理,就会一直显示,怎么样让它点击之后就消失呢?只要重写UITableView的代理方法,就可以解决,方式如下:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { //当手指离开某行时,就让某行的选中状态消失 [tableView deselectRowAtIndexPath:indexPath animated:YES]; }
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7) { //分别为top, left, bottom,right cell.separatorInset = UIEdgeInsetsMake(0, 10, 0, 0); }