jackson89
jackson89

Reputation: 203

using iosMath and SwiftUI

I'm trying to create a small math learning application.

So I installed iosMath, but using SwiftUI I don't know how to declare a MTMathUILabel.

Maybe someone has a lead to help me?

I tried this but got the following error message: "Constant'label' inferred to have type '()', which may be unexpected".


import SwiftUI
import UIKit
import iosMath

struct MyViewMath : View {

    let label = MTMathUILabel().latex="\\sum"

    var body: some View {
        GeometryReader { geo in
            VStack {
                View1()
                Text("\(label)")
                View2()
            }


        }
    }
}

// My view code bellow

Thanks for your help.

Upvotes: 1

Views: 662

Answers (1)

rob mayoff
rob mayoff

Reputation: 385920

MTMathUILabel is a UIView subclass, so you cannot use it directly in a SwiftUI View. Instead, you need to create a new type that conforms to UIViewRepresentable to wrap the MTMathUILabel. Tanu Singhal explains the process in detail in WWDC 2019 Session 231: Integrating SwiftUI.

Upvotes: 2

Related Questions