ios - 如何在swift中将标题视图背景颜色与表格视图分开
问题描述
所以我想从 Health App 中制作类似的东西,其中“收藏夹”标题与单元格分开。
这是我现在的用户界面:
所以我想在第一个单元格上制作背景曲线,而不是标题。那可能吗?
我一直在环顾四周,但没有得到任何解决方案。这是我到目前为止创建的代码:
func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
let label = UILabel()
label.text = "Smaller Title"
label.font = .boldSystemFont(ofSize: 22)
label.textColor = UIColor.black
label.backgroundColor = UIColor.clear
label.textAlignment = .left
label.translatesAutoresizingMaskIntoConstraints = false
let headerView = UIView()
headerView.backgroundColor = UIColor.clear
headerView.addSubview(label)
label.leftAnchor.constraint(equalTo: headerView.leftAnchor).isActive = true
return headerView
}
解决方案
这里UITableView
有一个.white
backgroundColor
. 尝试将 设置backgroundColor
为UITableView
并.clear
自定义UITableViewCells
以拥有.white
backgroundColor
.
tableView.backgroundColor = .clear
推荐阅读
- r - 如何在一张图上绘制多个密度?
- wordpress - 由于 htaccess,无法访问 Wordpress 目录之外的文件
- css - 由于 .scss 文件中的导入,React SCSS 模块无法正常工作
- hadoop - MSCK 维修表
显示没有错误但没有检测到任何分区 - node.js - 从解析器内部获取完整的查询字符串
- javascript - Angular 2+路由redirectTo作为函数
- java - PDFBOX 与 AEM 项目的集成
- apache - 重定向到 HTTPS,除了一系列 URL
- angular - Angular:全局变量在订阅函数内没有改变
- html - UIapplication 到 Html 脚本