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

2025-05-29 0 50

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

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

?

1

2

3

4

5

6
if(leftTable!.respondsToSelector("setLayoutMargins:")){

leftTable?.layoutMargins=UIEdgeInsetsZero

}

if(leftTable!.respondsToSelector("setSeparatorInset:")){

leftTable!.separatorInset=UIEdgeInsetsZero;

}

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

?

1

2

3

4

5

6

7

8
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空白间距),希望对大家以上帮助!

收藏 (0) 打赏

感谢您的支持,我会继续努力的!

打开微信/支付宝扫一扫,即可进行扫码打赏哦,分享从这里开始,精彩与您同在
点赞 (0)

声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。

快网idc优惠网 建站教程 ios8 UITableView设置 setSeparatorInset UIEdgeInsetsZero不起作用的解决办法(去掉15px空白间距) https://www.kuaiidc.com/92773.html

相关文章

发表评论
暂无评论