Set the color of the Finish button to the SFSafariViewController

I use SFSafariViewControllerto access a website with a name UITableViewController. Since my application has a very light feeling associated with it, I added the following line of code to AppDelegate:

self.window.tintColor = [UIColor whiteColor];

At startup, SFSafariViewControllerI get the following:

enter image description here

In any case, can I change the color of the button Doneto blue (default)?

I tried the following when called SFSafariViewController, but without effect:

        [self presentViewController:safariVC animated:YES completion:^{
            safariVC.navigationController.navigationItem.rightBarButtonItem.tintColor = [UIColor blueColor];


        [self presentViewController:safariVC animated:YES completion:^{
            safariVC.navigationController.navigationBar.tintColor = [UIColor blueColor];
        }];

None of them work.

I could, of course, leave the default application and pull the white parameter out AppDelegate, but I need this approach in the application because Blue just stands out too much with custom themes.

Any advice on this would really be appreciated.

+4
2

appearance :

[[UINavigationBar appearance] setTintColor:[UIColor blueColor]];
[[UIBarButtonItem appearance] setTintColor:[UIColor blueColor]];

else

  [self presentViewController:safariVC animated:YES completion:^{

         [safariVC.navigationBar setTintColor:[UIColor blueColor]];
    }];

else

AppDelegate.m :

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

:

//SFSafariViewController
[[UINavigationBar appearanceWhenContainedIn:[SFSafariViewController class], nil] setBarTintColor:[UIColor blueColor]];
[[UINavigationBar appearanceWhenContainedIn:[SFSafariViewController class], nil] setTintColor:[UIColor blueColor]];

ViewDidLoad

[self.navigationController.navigationBar setTintColor:[UIColor whiteColor]]; 

Swift

UINavigationBar.appearance().tintColor = UIColor.blueColor()
UIBarButtonItem.appearance().tintColor = UIColor.blueColor()

self.presentViewController(safariVC, animated: true, completion: {() -> Void in
safariVC.navigationBar.tintColor = UIColor.blueColor()
})

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

     UINavigationBar.appearanceWhenContainedIn(SFSafariViewController.self, nil).barTintColor = UIColor.blueColor()
UINavigationBar.appearanceWhenContainedIn(SFSafariViewController.self, nil).tintColor = UIColor.blueColor()
}

, ,

  self.navigationController.navigationBar.tintColor = UIColor.whiteColor()
+4

Try setPreferredControlTintColor ""

+2

Source: https://habr.com/ru/post/1614176/


All Articles