ios8 UITableView setting setSeparatorInset UIEdgeInsetsZero does not work (remove 15px blank space)
- 2020-05-15 02:11:40
- OfStack
But in ios8, setting setSeparatorInset:UIEdgeInsetsZero no longer works. Here's the solution:
First, add the following code to the viewDidLoad method:
if(leftTable!.respondsToSelector("setLayoutMargins:")){
leftTable?.layoutMargins=UIEdgeInsetsZero
}
if(leftTable!.respondsToSelector("setSeparatorInset:")){
leftTable!.separatorInset=UIEdgeInsetsZero;
}
Then add the following code to the UITableView proxy method:
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
if(cell!.respondsToSelector("setLayoutMargins:")){
cell!.layoutMargins=UIEdgeInsetsZero
}
if(cell!.respondsToSelector("setSeparatorInset:")){
cell!.separatorInset=UIEdgeInsetsZero;
}
}
If this happens, Table's divider will have no blank space.
The above content introduced to you ios8 UITableView setSeparatorInset UIEdgeInsetsZero set setSeparatorInset UIEdgeInsetsZero does not work solution (remove 15px blank space), I hope to help you above!