Reputation: 1256
I'm presenting a SFSafariViewController and am attempting to change the color of the navigation bar at the top, and have found resources when the view is presented in a UIViewController; But, I am presenting it in a UICell: e.g
viewController?.present(SFSafariViewController(url: URL(string: "https://apple.com")!), animated: true, completion: nil)
What is the correct way to change the bar tint on the top? This is what I'm referring to:
Upvotes: 2
Views: 233
Reputation: 14397
If you want to change bar colors as well as controls(Buttons) colors you can try this code
private func presentWebBrowser(with url : String){
if let url = URL(string: url) {
let vc = SFSafariViewController(url: url)
vc.preferredBarTintColor = .magenta
vc.preferredControlTintColor = .white
self.present(vc, animated: true, completion: nil)
} else {
print("URL not correct")
}
}
Upvotes: 0
Reputation: 5634
You can try this:
let vc = SFSafariViewController(url: URL(string: "https://apple.com")!)
vc.preferredBarTintColor = .red
self.present(vc, animated: true, completion: nil)
Upvotes: 1