在SFSafariViewController上设置完成按钮的颜色 [英] Set Done Button Colour on SFSafariViewController

查看:377
本文介绍了在SFSafariViewController上设置完成按钮的颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用SFSafariViewController访问从UITableViewController调用的网站.因为我的应用程序感觉很轻松,所以我在AppDelegate中添加了以下代码行:

I am using the SFSafariViewController to access a website called from a UITableViewController. Because my app has a very light feel attached to it, I have added the following line of code in the AppDelegate:

self.window.tintColor = [UIColor whiteColor];

运行SFSafariViewController时,我得到以下信息:

When running the SFSafariViewController, I get the following:

反正我可以将Done按钮的颜色更改为蓝色(默认情况下)吗?

Is there anyway I can change the colour of the Done button to Blue (as per default)?

我在调用SFSafariViewController时尝试了以下操作,但没有效果:

I've tried the following when calling the SFSafariViewController but to no 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];
        }];

这些都不起作用.

我当然可以将应用程序保留为默认设置,并从AppDelegate中删除白色设置,但是我希望在应用程序内使用这种方法,因为蓝色在自定义主题方面显得过于突出.

I could of course leave the app as default and take out the white setting from the AppDelegate, but I want this approach within the app because Blue just stands out too much with custom themes.

任何对此的指导将不胜感激.

Any guidance on this would be really appreciated.

推荐答案

您可以使用appearance代理全局更改条形颜色:

You can change bar colours globally using appearance proxy:

尝试

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

否则尝试

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

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

否则尝试

在AppDelegate.m中的功能:

in AppDelegate.m in the function:

- (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

or add in your ViewDidLoad

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

快速

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()

这篇关于在SFSafariViewController上设置完成按钮的颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆