7

Ich möchte die Farbe meines rechten Balkenknopfes von Schwarz zu Weiß ändern. Es ist ein Knopf als Suchsymbol. Ich habe die Suchimplementierung noch nicht codiert, da ich die Hauptschnittstelle zuerst fertigstellen möchte. Ich dachte, ich hätte die richtigen Codes geschrieben, damit sie weiß erscheinen, aber im Storyboard und im Simulator scheint sie immer noch schwarz zu sein.Wie ändert man TintColor von UIBarButtonItem in Swift?

Im Storyboard habe ich es auch auf weiß gesetzt.

Hier ist mein Code, der in der AppDelegate.swift Datei befindet:

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 des Simulators:

enter image description here

ich es, dass diese Codezeile ungerade finden funktioniert nicht. Irgendeine Lösungsmöglichkeit?

+1

Haben Sie versucht 'UIBarButtonItem.Appearance(). TintColor = UIColor.GreenColor()' –

+0

@RashwanL Ich versuchte dies, aber es ist immer noch schwarz. Ich möchte, dass es weiß ist. –

+0

'UINavigationBar.Appearance(). TintColor = UIColor.whiteColor()' sollte funktionieren.Sie müssen die 'tintColor' in eine andere Farbe irgendwo in Ihrem Code ändern – Leo

Antwort

0

Das Problem war, dass die Schaltfläche automatisch als benutzerdefinierte festgelegt wurde. Ich habe es zum System umgestaltet.

Verwandte Themen