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

4
我们正在使用Obj-C更改工具栏按钮项标题的颜色。
    [_anyToolbarButton setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys: [UIColor lightGrayColor], NSForegroundColorAttributeName,nil] forState:UIControlStateNormal];

但是当我使用Swift时,无法进行更改。

2个回答

5

在Swift中,您可以这样做:

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

那个可以,我应该之前就问了,浪费了这么多时间。 - Hope

0
toolbar.tintColor = UIColor.red

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接