swift - UITableView titleForHeaderInSection 很大,字体不同
问题描述
我试图让它看起来就像设置页面一样。但是,当我向标题添加标题时,字体看起来是:粗体、comic sans 和 18pt。有任何想法吗?
我尝试了下面的故事板和代码:
override func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
return ("hi")
}
解决方案
您可以实现 UITableView 可选方法 viewForHeaderInSection 并返回具有所需字体和大小的自定义标签
func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView?
如果您需要在 section 中为 Header 指定不同的高度,则还需要实现可选方法 heightForHeaderInSection。
func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat
推荐阅读
- android -
在 Android Studio 4.0.2 - python-3.x - Python:Base64 解码编解码器无法解码位置 47-48 中的字节:无效的继续字节
- javascript - 反应 setTimeout - 内存泄漏
- c# - 如何中断从 c# interop 调用的 c++ 代码
- python - 求嵌套循环的时间复杂度
- python-3.x - python中的zip功能表现得很奇怪
- c# - 如何使用配置注册 Autofac 模块
- python - 通过python生成OTP
- ios - 为 iOS 构建分发时,Appcelerator 中的存档失败
- twitter-bootstrap - 使用相同的模态制作不同的链接,每个链接显示不同的轮播