//调整边距 UIEdgeInsetsZero 为全屏显示
UIEdgeInsetsMake(0, kScreenWidth, 0, 0) 这个是隐藏某一行
-(void)setLastCellSeperatorToLeft:(UITableViewCell*)cell
{
if([cellrespondsToSelector:@selector(setSeparatorInset:)]) {
[cellsetSeparatorInset:UIEdgeInsetsMake(0, kScreenWidth, 0, 0)];//UIEdgeInsetsZero
}
if([cellrespondsToSelector:@selector(setLayoutMargins:)]) {
[cellsetLayoutMargins:UIEdgeInsetsMake(0, kScreenWidth, 0, 0)];
}
if([cellrespondsToSelector:@selector(setPreservesSuperviewLayoutMargins:)]){
[cellsetPreservesSuperviewLayoutMargins:NO];
}
}
//调用
-(UITableViewCell* )tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath {
YMMeCell* cell = [YMMeCell shareCell];
cell.titlLabel.text=self.titlesArr[indexPath.section][indexPath.row];
cell.iconImgView.image= [UIImageimageNamed:self.iconsArr[indexPath.section][indexPath.row]];
//最后一行分割线顶头显示
NSArray* sectTitlArr =self.titlesArr[indexPath.section];
if(indexPath.row== sectTitlArr.count-1) {
[self setLastCellSeperatorToLeft:cell] ;
}
returncell;
}
或者在自定义cell里面,在awakeFromNib 添加代码
- (void)awakeFromNib {
[super awakeFromNib];
[self setSeparatorInset:UIEdgeInsetsMake(0, kScreenWidth, 0, 0)];
[self setLayoutMargins:UIEdgeInsetsMake(0, kScreenWidth, 0, 0)];
}
网友评论