ios8 UITableView设置 setSeparatorInset UIEdgeInsetsZero不起作用的解决办法(去掉15px空白间距)

前端技术 2023/09/04 IOS

但是在ios8中,设置setSeparatorInset:UIEdgeInsetsZero 已经不起作用了。下面是解决办法:

首先在viewDidLoad方法加入以下代码:

if(leftTable!.respondsToSelector(\"setLayoutMargins:\")){
leftTable?.layoutMargins=UIEdgeInsetsZero
}
if(leftTable!.respondsToSelector(\"setSeparatorInset:\")){
leftTable!.separatorInset=UIEdgeInsetsZero;
}

然后在UITableView的代理方法中加入以下代码:

func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
if(cell!.respondsToSelector(\"setLayoutMargins:\")){
cell!.layoutMargins=UIEdgeInsetsZero
}
if(cell!.respondsToSelector(\"setSeparatorInset:\")){
cell!.separatorInset=UIEdgeInsetsZero;
}
}

这样不出意外的话,Table的分割线就没有空白间距了。

以上内容给大家介绍了ios8 UITableView设置 setSeparatorInset UIEdgeInsetsZero不起作用的解决办法(去掉15px空白间距),希望对大家以上帮助!

本文地址:https://www.stayed.cn/item/11197

转载请注明出处。

本站部分内容来源于网络,如侵犯到您的权益,请 联系我

我的博客

人生若只如初见,何事秋风悲画扇。