ios swift tableView insetGrouped 圆角 组间距

该文章介绍了如何在iOS开发中,针对UITableView的insetGrouped样式设置单元格圆角以及调整组间距的方法。通过实现UITableView的代理方法`heightForHeaderInSection`和`heightForFooterInSection`来设定组头和组尾的高度,并通过`viewForHeaderInSection`和`viewForFooterInSection`来控制视图显示,从而达到预期效果。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1.圆角

参考博客:
「iOS」UITableView.Style.insetGrouped样式 及 代码实现圆角cell 方案 - 知乎

2.组间距

    func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
        0
    }
     
    func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
        10
    }

要实现下面两个代理方法,上面的两个代理方法才会生效

    func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
        nil
    }
    
    func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
        nil
    }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值