ios - 为什么当我单击 UIBarButtonItem 时它会调整大小?
问题描述
每当我单击具有 unicode 标题以显示 cog 符号的 UIBarButtonItem 时,它会调整大小并变小。这是代码:
let settings = UIBarButtonItem(title: NSString(string: "\u{2699}\u{0000FE0E}") as String, style: .plain, target: self, action: #selector(show_settings))
let font = UIFont.systemFont(ofSize: 28)
let attributes = [NSAttributedStringKey.font : font]
settings.setTitleTextAttributes(attributes, for: .normal)
解决方案
为突出显示的状态以及以下设置 TitleAttributes:
let settings = UIBarButtonItem(title: NSString(string: "\u{2699}\u{0000FE0E}") as String, style: .plain, target: self, action: #selector(show_settings))
let font = UIFont.systemFont(ofSize: 28)
let attributes = [NSAttributedStringKey.font : font]
settings.setTitleTextAttributes(attributes, for: .normal)
settings.setTitleTextAttributes(attributes, for: .highlighted)
希望这会帮助你:)
推荐阅读
- php - 如何使用php将json序列化数据添加到数据库中
- node.js - dgram node js客户端等待服务器启动
- c# - WPF MVVM:一旦不再显示视图,如何避免重新加载视图
- jmeter - 如何传递多个 CSV/JSON 文件,这些内容应在 POST 正文数据中设置?
- c++ - 我得到一个非法引用和一个不允许的类型名称,为什么?
- c# - 为什么这个 yield break 没有打破循环?
- c - 函数内部结构失效的 Malloc
- azure - 通过 Microsoft Azure 中的 docker-compose 使用 SQLite 的 WebAPI
- amazon-web-services - 如何将 terraform 与 AWS 提供商和本地编辑器一起使用?
- java - 从 JUnit 类调用 Java 主方法