首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何在表视图中快速地将节脚注固定在某个特定脚注的末尾

如何在表视图中快速地将节脚注固定在某个特定脚注的末尾
EN

Stack Overflow用户
提问于 2020-06-29 22:12:09
回答 1查看 34关注 0票数 1

我在这里和第一节有一些部分,我有这个页脚作为附加信息。但当我滚动屏幕时,它一直在浮动。我怎么才能阻止它?我怎么把它放在部分下面呢?我正在使用viewForFooterInSection,下面是我的代码:

代码语言:javascript
复制
override func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
    let footerView = UIView()
    if section == 1 {
        let label = UILabel()
        label.text = "A sticky footer here..."
        label.font = .systemFont(ofSize: 16)
        label.textColor = UIColor.gray
        label.backgroundColor = UIColor.clear
        label.textAlignment = .left
        footerView.addSubview(label)
        label.translatesAutoresizingMaskIntoConstraints = false
        label.topAnchor.constraint(equalTo: footerView.topAnchor, constant: 10).isActive = true
        label.leftAnchor.constraint(equalTo: footerView.leftAnchor, constant: 20).isActive = true
        label.rightAnchor.constraint(equalTo: footerView.rightAnchor).isActive = true
        label.bottomAnchor.constraint(equalTo: footerView.bottomAnchor).isActive = true
    }
    return footerView
}

我想让它保持粘性,在我的第一部分下。我该怎么做?

提前谢谢你

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-06-29 22:56:36

您应该使用分组样式初始化表视图。

let tableView = UITableView(frame: .zero, style: .grouped)

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/62640035

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档