动态更改UITableView Footer高度

override 所在UIViewController的 viewDidLayoutSubviews方法

override func viewDidLayoutSubviews() {
        super.viewDidLayoutSubviews()
        
        if let footView = tableView.tableFooterView {
        //footerContentView 是footerView的内容视图,它使用自动布局来自适应高度,然后在代码里面获取高度变更footerView 的高度
            let height = footerContentView.systemLayoutSizeFittingSize(UILayoutFittingCompressedSize).height
            if height != footerView.frame.height {
                print("new height=\(height)")
                footView.frame.size.height = height
                tableView.tableFooterView = footView
            }
        }
    }
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • /* UIViewController is a generic controller base class th...
    DanDanC阅读 5,855评论 0 2
  • 前言的前言 唐巧前辈在微信公众号「iOSDevTips」以及其博客上推送了我的文章后,我的 Github 各项指标...
    VincentHK阅读 10,770评论 3 44
  • 1.自定义控件 a.继承某个控件 b.重写initWithFrame方法可以设置一些它的属性 c.在layouts...
    圍繞的城阅读 8,819评论 2 4
  • UIViewController 的生命周期答:来源:http://www.cnblogs.com/dahe007...
    IreneWu阅读 3,805评论 1 2
  • Spring Cloud为开发人员提供了快速构建分布式系统中一些常见模式的工具(例如配置管理,服务发现,断路器,智...
    卡卡罗2017阅读 135,323评论 19 139