gpt4 book ai didi

swift - 将 rightBarButtonItem 设为粗体

转载 作者:行者123 更新时间:2023-11-30 10:34:39 27 4
gpt4 key购买 nike

我正在尝试设置一个导航按钮,使其显示为红色和半粗体。我设法更改了颜色,但在将其更改为半粗体时遇到了问题:

navigationItem.rightBarButtonItem = UIBarButtonItem(title: "Sign Up", style: .plain, target: self, action: #selector(signIn))
navigationItem.rightBarButtonItem?.tintColor = .red
UIBarItem.appearance().setTitleTextAttributes(
[
NSAttributedString.Key.font: UIFont.systemFont(ofSize: 12, weight: .semibold)
],
for: .normal)

我首先尝试了 rightBarButtonItem.appearance 但这似乎不是一个选项。

我正在使用 Swift 4.2。

最佳答案

您可以将 style 属性设置为 .done 以使 UIBarButtonItem 粗体。这将一直有效,直到 Apple 更改完成按钮在较新版本的 iOS 中的外观。

navigationItem.rightBarButtonItem?.style = .done

关于swift - 将 rightBarButtonItem 设为粗体,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58346376/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com