2

I can change bottom UI bar with:

UIBarButtonItem.appearance().tintColor = UIColor.redColor()

Can't locate how to do same with top-right "Done" button.

Here's where that works in AppDelegate.swift:

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
    // Override point for customization after application launch.
    UIBarButtonItem.appearance().tintColor = UIColor.redColor()

    return true
}

Adding this does not work:

UINavigationBar.appearance().tintColor = UIColor.redColor()
Mick MacCallum
  • 129,200
  • 40
  • 280
  • 281
user1452893
  • 838
  • 1
  • 11
  • 29

3 Answers3

2

To change de Done button color and also the bottom UI bar you have to set the tintColor property of the SFSafariViewController's view

example:

let webVC = SFSafariViewController(URL: yourURL)
webVC.view.tintColor = UIColor.redColor()
Adrian
  • 16,233
  • 18
  • 112
  • 180
0

Ismael's answer didn't work in iOS 10 for me. Since iOS 10 SFSafariViewController has a property preferredControlTintColor to set the color of the buttons. Another new property is preferredBarTintColor fyi.

This is my approach in Swift 3:

let svc = SFSafariViewController(url: URL(string: "<YOUR_URL_STRING>")!)

if #available(iOS 10.0, *) {
    svc.preferredControlTintColor = UIColor.red
} else {
    svc.view.tintColor = UIColor.red
}

self.present(svc, animated: true, completion: nil)
Matthew Frederick
  • 22,245
  • 10
  • 71
  • 97
-1

Adding this works:

UIButton.appearance().tintColor = UIColor.redColor()
Eric Aya
  • 69,473
  • 35
  • 181
  • 253
user1452893
  • 838
  • 1
  • 11
  • 29