gpt4 book ai didi

ios - 如何为 SFSafariViewController 中的控件设置自定义字体?

转载 作者:行者123 更新时间:2023-11-28 13:50:12 25 4
gpt4 key购买 nike

除了颜色之外,我还没有看到任何自定义 SFSafariViewController 的方法,所以我想知道是否有人找到了解决方法,特别是针对控件的字体。 ( swift 4、iOS 12 等)

最佳答案

SFSafariViewController 主要用于在应用程序中显示网页内容。您可以在要在 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)

关于ios - 如何为 SFSafariViewController 中的控件设置自定义字体?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54775374/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com