I haven't seen any ways to customize SFSafariViewController besides color, so I was wondering if anyone found a workaround, specifically for the font of the controls. (Swift 4, iOS 12, etc.)
Asked
Active
Viewed 461 times
0
-
I think SFSafariViewController was not meant to be all that customizable. You may have to look into using WKWebView if you want more control. – moger777 Feb 19 '19 at 22:19
1 Answers
1
SFSafariViewController is intended to be used majorly for showing a web content within application. Level of customisation you can achieve on a page to be rendered in SFSafariViewController is really low. Apple mentions to use it majorly to show a webpage with your app.
For overriding/ customising web page, you should use WKWebView. It gives functions that will help you customising HTML/ JS content like evaluateJavaScript // This will give you option to perform your action on existing JS loaded in page
With WKWebView, you may do something like this when you load page in 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)

Abhinav Saldi
- 44
- 1
- 5