WKWebView Reader View
You cannot enable "Reader" mode for WKWebView (or UIWebView).
Edit: You can however do this with SFSafariViewController as seen in the other solution.
It occurs to me that it would be possible to modify the HTML code of the website to make it look more like Reader. It seems that there are services that already do this, like Readability:
Just load this URL into your WKWebView: http://www.readability.com/m?url=YOUR_URL_HERE
This should help you achieve a similar function to Reader.
@dfmuir is right, UIWebView or WKWebView do not provide a Reader Mode. However as Baig said you can use a SFSafariViewController to achieve this. Here we go with a simple and working Swift code to do so:
import UIKit
import SafariServices
class ViewController: UIViewController {
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(true)
let urlString = "http://google.com"
let url = URL(string: urlString)
let safariVC = SFSafariViewController(url: url!, entersReaderIfAvailable: true)
present(safariVC, animated: true, completion: nil)
}
}
Just improve @dzensik answer, because 'init(url:entersReaderIfAvailable:)' was deprecated in iOS 11.0.
import UIKit
import SafariServices
class ViewController: UIViewController {
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(true)
let urlString = "http://google.com"
let url = URL(string: urlString)
let configuration = SFSafariViewController.Configuration()
configuration.entersReaderIfAvailable = true
let safariVC = SFSafariViewController(url: url!, configuration: configuration)
present(safariVC, animated: true, completion: nil)
}
}