You can use KatexMathe View
you can download this library
//MARK:- IBOutlet
@IBOutlet weak var webViewQuestion: KatexMathView!
override func viewDidLoad() {
super.viewDidLoad()
self.webViewQuestion.loadLatex("your string")
}
extension ReadQuestionVC : WKNavigationDelegate {
public func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
self.webViewQuestionHC.constant = 10 //Default constant height
self.setContaintSizeWebView(webView: webViewQuestion, constantSize: self.webViewQuestionHC)
}
func setContaintSizeWebView(webView:WKWebView,constantSize:NSLayoutConstraint){
webView.evaluateJavaScript("document.readyState", completionHandler: { (complete, error) in
if complete != nil {
webView.evaluateJavaScript("Math.max(document.body.scrollHeight, document.body.offsetHeight, document.documentElement.clientHeight, document.documentElement.scrollHeight, document.documentElement.offsetHeight)", completionHandler: { (height, error) in
constantSize.constant = height as! CGFloat
webView.sizeToFit()
self.view.layoutIfNeeded()
})
}
})
}
}