ios - 在 iOS 上原生渲染 UILabel/UITextfield 中的 LaTeX 代码

标签 ios swift latex

我想在我的应用程序中渲染 LaTeX。我已经尝试过iOSMathiOSLatex .

问题是 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

you can download this library

Example here

//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/

相关文章:

ios - 如何旋转到只有一个 View Controller 的横向

ios - 将 .swift 文件导入 Objective-C 文件会导致方法声明错误缺少上下文

ios - 如何使用缓存使用 SfSafariView 或 WKWebView 更快地加载网站?

swift - 如何快速安装 Google-Maps-iOS-Utils?

ios - GCD设置线程间的调度/优先级

ios - 火力地堡分析 : Install Referrer: iOS app

latex - 如何用它们的定义替换 latex 宏(使用 latex )

android - MySQL 到 Sqlite 从 PHP 同步到移动应用程序 (iOS/Android)

text - 如何在 LaTeX 表格中换行文本?

latex - 如何在 LaTeX 中\include 之后没有分页符