【发布时间】:2018-05-25 03:51:53
【问题描述】:
我是编程新手,但我对如何在 iOS 上使用 iosMath 很感兴趣。我已经可以安装 Cocoa Pod 并且我确实将 iosMath 导入到项目中。问题是:如何可视化数学方程?
我知道它应该使用MTMathUILabel,但是我不知道如何将它添加到程序中。有没有办法创建UIView 的子类或其他东西,以便能够做到?
这里是我的代码示例:
import UIKit
import Foundation
import CoreGraphics
import QuartzCore
import CoreText
import iosMath
class ViewController: UIViewController {
@IBOutlet weak var label: MTMathUILabel!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
let label: MTMathUILabel = MTMathUILabel()
label.latex = "x = \\frac{-b \\pm \\sqrt{b^2-4ac}}{2a}"
label.sizeToFit()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
我尝试在我的 Storyboard 中将标签连接到 UIView() 和 UILabel(),但显然不是这样。
提前感谢您的帮助。
【问题讨论】: