iOS7 iOS8 tableview separatorInset cell分割線左對齊

  iOS7 和 iOS8 中tableview cell分割線左對齊的方法不同,特此爲之後須要作筆記。blog

  iOS7 中方法很簡單,只須要設置 _table.separatorInset = UIEdgeInsetsMake(0, 0, 0, 0);table

  而iOS8 中方法須要寫一段代碼:class

  

-(void)viewDidLayoutSubviews {
    if ([_table respondsToSelector:@selector(setSeparatorInset:)]) {
        [_table setSeparatorInset:UIEdgeInsetsZero];
    }
    if ([_table respondsToSelector:@selector(setLayoutMargins:)])  {
        [_table setLayoutMargins:UIEdgeInsetsZero];
    }
}

-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath{
  
       if ([cell respondsToSelector:@selector(setLayoutMargins:)]) {
           [cell setLayoutMargins:UIEdgeInsetsZero];
       }
       if ([cell respondsToSelector:@selector(setSeparatorInset:)]){
            [cell setSeparatorInset:UIEdgeInsetsZero];
       }
    
}
相關文章
相關標籤/搜索