iOS 9 UITableView separators insets (significant left margin)

后端 未结 11 2108
故里飘歌
故里飘歌 2020-12-02 16:41

I have a problem with separators between UITableViewCells in UITableView on iOS 9. They have the significant left margin. I already ha

11条回答
  •  北海茫月
    2020-12-02 17:25

    - (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
    
        // Remove seperator inset
    
        if ([cell respondsToSelector:@selector(setSeparatorInset:)]) {
            [cell setSeparatorInset:UIEdgeInsetsZero];
        }
    
        // Prevent the cell from inheriting the Table View's margin settings
    
        if ([cell respondsToSelector:@selector(setPreservesSuperviewLayoutMargins:)]) {
            [cell setPreservesSuperviewLayoutMargins:NO];
        }
    
        // Explictly set your cell's layout margins
    
        if ([cell respondsToSelector:@selector(setLayoutMargins:)]) {
            [cell setLayoutMargins:UIEdgeInsetsZero];
        }
    
    }
    

提交回复
热议问题