So ändern Sie tintColor von UIBarButtonItem in Swift?

Ich die Farbe ändern wollen meiner rechten bar button item von schwarz zu weiß. Es wird eine Schaltfläche als Symbol "suchen". Ich habe nicht codiert der Suche Implementierung noch nicht, wie ich will, um die wichtigste Schnittstelle zuerst abgeschlossen. Ich dachte, ich hätte geschrieben, die richtigen codes sollte es also so erscheinen, als weiß, aber es scheint immer noch als schwarz angezeigt, in der sowohl das storyboard und Simulation.

In das storyboard, ich habe auch auf weiß eingestellt.

Hier ist mein code, welcher sich in der AppDelegate.swift Datei:

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {

    //Changing the status bar's colour to white
    UIApplication.sharedApplication().statusBarStyle = .LightContent

    //Changing the navigation controller's background colour
    UINavigationBar.appearance().barTintColor = UIColor(red: 0.0/255.0, green: 165.0/255.0, blue: 227.0/255.0, alpha: 1.0)

    //Changing the navigation controller's title colour
    UINavigationBar.appearance().titleTextAttributes = [NSForegroundColorAttributeName: UIColor.whiteColor()]

    //Changing the colour of the bar button items
    UINavigationBar.appearance().tintColor = UIColor.whiteColor()

    //Changing the tint colour of the tab bar icons
    UITabBar.appearance().tintColor = UIColor(red: 0.0/255/0, green: 165.0/255.0, blue: 227.0/255.0, alpha: 1.0)

    return true
}

Hier ist ein Bild von dem simulator:

So ändern Sie tintColor von UIBarButtonItem in Swift?

Ich finde es seltsam, dass diese Zeile code funktioniert nicht. Jede Lösung?

  • Haben Sie versucht UIBarButtonItem.appearance().tintColor = UIColor.greenColor()
  • Ich habe versucht, aber es ist immer noch schwarz. Ich will es, weiß zu sein.
  • UINavigationBar.appearance().tintColor = UIColor.whiteColor() funktionieren sollte.Sie müssen ändern Sie die tintColor anderen Farbe irgendwo in deinem code
  • Dies hat nicht funktioniert.
InformationsquelleAutor | 2016-01-05
Schreibe einen Kommentar