swift - 如何使用 Swift 更改工具栏按钮项目标题颜色

标签 swift colors toolbar title

我们在 Obj-C 中使用

更改工具栏按钮项目标题颜色
    [_anyToolbarButton setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys: [UIColor lightGrayColor], NSForegroundColorAttributeName,nil] forState:UIControlStateNormal];

但在使用 Swift 时我无法更改。

最佳答案

你可以快速地这样做:

_anyToolbarButton.setTitleTextAttributes([NSForegroundColorAttributeName: UIColor.lightGrayColor()], forState: .Normal)

关于swift - 如何使用 Swift 更改工具栏按钮项目标题颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32344663/

相关文章:

toolbar - 如何在 DeskBand 任务栏工具栏上强制使用 C# 呈现 ComboBox 的 GDI+? (透明度问题)

ios - 如何打开 Instagram 查询方案以分享到故事?

ios - ipatool 失败,出现异常 : #<CmdSpec: NonZeroExcitException>: Command exited with pid 69299 exit 1:

ios - 闭包无法隐式捕获变异的 self 参数

ios - Swift 5 URLRequest 授权头 : reserved, 如何设置?

java - 在 Java 中,努力返回颜色

linux - 如何让 Xvfb 在 32 位颜色上工作

java - java处理中如何一键来回改变背景颜色?

ios - 将工具栏定位在屏幕顶部,底部有正确的阴影

android - 如何在android中为工具栏的appcompat Activity 设置导航主页按钮?