Swift

[Swift] 변수와 text 문구 표시 및 Bool일때

우니010 2023. 11. 27. 21:12
반응형
import SwiftUI

struct Variable: View {
    
    let name = "nawon"
    
    var body: some View {
        VStack {
            Text(name)
            Text(name)
            Text("hello, \(name)")
        }
        
    }
}

#Preview {
    Variable()
}

 

 

 

import SwiftUI

struct Variable: View {
    
    let name = "nawon"
    let age:Int = 20
    let hasJob: Bool = true
    
    var body: some View {
        VStack {
            Text(name)
            Text(name)
            Text("hello, \(name) \(age) \(hasJob.description)")
        }
        
    }
}

#Preview {
    Variable()
}

 

\(hasJob.description) 하면 true / false 텍스트로 표시해준다

반응형