Create unitfields in swiftUI
Solution:
If you want to create textfield with units on right side then use the below code..
struct unitField: View {
@State var textValue:String = ""
@State var unitFieldValue:String = ""
var body: some View {
let stack = HStack {
TextField("", text: $unitFieldValue)
.background(Color.themeTextField)
.cornerRadius(10.0)
.border(Color.gray, width: 1)
Text(textValue).background(Color.titleBackColor)
} .frame(minWidth: 0, maxWidth: .infinity,minHeight: 30, maxHeight: .infinity,alignment: .leading)
return stack
}
}
Comments
Post a Comment