Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 在SFSafariViewController上设置完成按钮颜色_Ios_Objective C_Iphone_Swift_Sfsafariviewcontroller - Fatal编程技术网

Ios 在SFSafariViewController上设置完成按钮颜色

Ios 在SFSafariViewController上设置完成按钮颜色,ios,objective-c,iphone,swift,sfsafariviewcontroller,Ios,Objective C,Iphone,Swift,Sfsafariviewcontroller,我正在使用SFSafariViewController访问一个名为UITableViewController的网站。因为我的应用程序附带了一种非常轻的感觉,所以我在AppDelegate中添加了以下代码行: self.window.tintColor = [UIColor whiteColor]; 运行SFSafariViewController时,我得到以下信息: 我是否可以将Done按钮的颜色更改为蓝色(根据默认设置) 调用SFSafariViewController时,我尝试了以下操作

我正在使用
SFSafariViewController
访问一个名为
UITableViewController
的网站。因为我的应用程序附带了一种非常轻的感觉,所以我在
AppDelegate
中添加了以下代码行:

self.window.tintColor = [UIColor whiteColor];
运行
SFSafariViewController
时,我得到以下信息:

我是否可以将
Done
按钮的颜色更改为蓝色(根据默认设置)

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

        [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
中去掉白色设置,但我希望在应用程序中使用这种方法,因为蓝色在自定义主题中太显眼了


如果您能就此提供指导,我们将不胜感激

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

试一试

否则试试

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

         [safariVC.navigationBar setTintColor:[UIColor blueColor]];
    }];
否则试试

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

         [safariVC.navigationBar setTintColor:[UIColor blueColor]];
    }];
在函数的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()
试一试 setPreferredControlTintColor
要设置“完成”按钮的色调颜色,请参见此链接。谢谢@Anbu-这非常有用。不幸的是,无论我从你的答案、链接和任何其他答案中尝试了什么,我都无法让它工作。它在SFSafariViewController中不会显示为蓝色。你有什么进一步的想法吗?这就是我提交答案的方式,我会用所有的方法,或者在新/旧的Xcode版本中检查一下,你是否让它在设备/模拟器上工作?我有self.window.tintColor=[UIColor-whiteColor];在AppDelegate中,我认为这是最重要的。这对我来说很重要,因为我希望每个后退按钮(导航控制器)都是白色的,但我就是不能让蓝色显示出来。酷,我知道了,伙计。我删除了self.window.tintColor=[UIColor-whiteColor];在AppDelegate中,默认返回蓝色,在每个ViewController中,我添加[self.navigationController.navigationBar setTintColor:[UIColor whiteColor];到viewDidLoad,它就可以工作了。谢谢你对这个人的帮助!我很感激!您确实应该添加一些解释,说明为什么这样做会起作用-您还可以添加代码以及代码本身中的注释-在其当前形式中,它没有提供任何解释来帮助社区其他人理解您为解决/回答问题所做的事。这对于一个老问题和已经有答案的问题来说尤其重要。这真的很简单<代码>让svc=SFSafariViewController(url:url)svc.preferredBarTintColor=.black svc.preferredControlTintColor=.yellow
第一个为条着色,第二个为控件着色。它节省了我的时间,应该是正确的答案!