我想在我的应用程序中渲染 LaTeX。我已经尝试过iOSMath和 iOSLatex .
问题是 iOS Math 不支持带有文本的 Latex,而 iOS Latex 在 WkWebview 上呈现 Latex 并截取屏幕截图并返回图像。
我们有 LaTeX 的原生渲染器(在 iOS 上)吗?
我正在尝试渲染
Solve this equation (\left{\begin{matrix} 3x + 2y - 11 = 0 \ 2x + 3y - 9 = 0 \end{matrix}\right.)
最佳答案
您可以使用 KatexMathe View
//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()
})
}
})
}
}
关于ios - 在 iOS 上原生渲染 UILabel/UITextfield 中的 LaTeX 代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60029546/