我正在使用 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
中删除白色设置,但我希望在应用程序中使用这种方法,因为蓝色在自定义主题方面过于突出。
任何关于这方面的指导将不胜感激。
最佳答案
您可以使用appearance
代理全局更改条形颜色:
尝试
[[UINavigationBar appearance] setTintColor:[UIColor blueColor]];
[[UIBarButtonItem appearance] 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()
关于ios - 在 SFSafariViewController 上设置完成按钮颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33482943/