除了颜色之外我还没有看到任何自定义SFSafariViewController的方法,所以我想知道是否有人找到了解决方法,特别是控件的字体。 (Swift 4,iOS 12等)
SFSafariViewController主要用于在应用程序中显示Web内容。您可以在要在SFSafariViewController中呈现的页面上实现的自定义级别非常低。 Apple提到主要使用它来显示您的应用程序的网页。
对于覆盖/自定义网页,您应该使用WKWebView。它提供的功能可以帮助您自定义HTML / JS内容,例如evaluateJavaScript //这将为您提供对页面中加载的现有JS执行操作的选项
使用WKWebView,当您在WKWebView中加载页面时,可以执行类似的操作。
webView.loadHTMLString("<head><meta charset='utf-8'><meta name='viewport' content='width=device-width, initial-scale=1, shrink-to-fit=no'><meta name='theme-color' content='#000000'><meta name='viewport' content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0' /><meta name='theme-color' content='#5A9C14'><meta name='msapplication-navbutton-color' content='#5A9C14'><meta name='apple-mobile-web-app-status-bar-style' content='#5A9C14'><link href='https://fonts.googleapis.com/css?family=Roboto' rel='stylesheet'><style>:root,* {font-family: 'Roboto', sans-serif;font-size: 14px;color: rgb(114, 114, 114);text-align: justify;-webkit-user-select: none;user-select: none;}</style></head><body>\(htmlIsi)</body>", baseURL: nil)