2014-09-05 84 views
0
func barButtonSelected(button:UIBarButtonItem){ 


    for vi in topNav!.items { 
     vi.tintColor = UIColor.redColor() 
    } 

    button.tintColor = UIColor(hex: "FF0000") 

} 

的FUNC是UIBarButtonItem'action,我可以改变我的录音按钮的tintcolor,但不能改变别人,Xcode的节目无法分配tintColor到“六”的错误,由它的方式是一个SWIFT代码不能改变uitoolbarbuttonitem颜色

+0

工具栏项目可能会被工具栏的背景颜色进行着色。尝试更改topNav.backgroundColor。我没有使用工具栏设置项目,所以我现在不打算自己测试它。 – mitrenegade 2014-09-05 03:55:22

回答

0

使用垂头丧气,检查这个代码:

func barButtonSelected(button:UIBarButtonItem){ 


    for vi in topNav!.items { 
     let theVi = vi as UIBarButtonItem 
     theVi.tintColor = UIColor.redColor() 
    } 

    button.tintColor = UIColor(hex: "FF0000") 

}