Sri*_*lli 12 iphone objective-c uitoolbar swift sfsafariviewcontroller
预期输出:我想将ToolBar颜色更改为深黑色.
实际输出:ToolBar为浅灰色.
这是代码:
let webViewController = SFSafariViewController(URL: url, entersReaderIfAvailable: true)
self.navigationController?.toolbar.barTintColor = UIColor.blackColor()
self.navigationController?.toolbar.tintColor = UIColor.whiteColor()
self.navigationController?.toolbar.barStyle = UIBarStyle.Black
self.navigationController?.pushViewController(webViewController, animated: true)
Run Code Online (Sandbox Code Playgroud)
Leo*_*ica 22
更新了iOS 10 API的答案
SFSafariViewController现在有preferredBarTintColor和preferredControlTintColor属性来控制工具栏的外观.
原始答案
SFSafariViewController渲染过程.您只能更改色调颜色,但不能更改条形样式或条纹色调.
要设置色调颜色,请设置Safari控制器视图的色调颜色,如下所示:
let sfController = SFSafariViewController(URL: url, entersReaderIfAvailable: true)
sfController.view.tintColor = UIColor.redColor()
navigationController?.showViewController(sfController, sender: self)
Run Code Online (Sandbox Code Playgroud)
有两种方式:
let resetPasswordSafari = SFSafariViewController(url: url, entersReaderIfAvailable: true)
resetPasswordSafari.preferredBarTintColor = .mainColor
resetPasswordSafari.preferredControlTintColor = .black
Run Code Online (Sandbox Code Playgroud)
和:
class ResetPasswordSafariViewController: SFSafariViewController {
override init(url URL: URL, entersReaderIfAvailable: Bool) {
super.init(url: URL, entersReaderIfAvailable: entersReaderIfAvailable)
delegate = self
preferredBarTintColor = .blue
preferredControlTintColor = .black
}
}
// MARK: - SFSafariViewControllerDelegate
extension ResetPasswordSafariViewController: SFSafariViewControllerDelegate {
internal func safariViewControllerDidFinish(_ controller: SFSafariViewController) {
controller.dismiss(animated: true)
}
}
Run Code Online (Sandbox Code Playgroud)
祝大家好运!
| 归档时间: |
|
| 查看次数: |
5881 次 |
| 最近记录: |