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

Popular posts from this blog

Invalid bundle error while upload the app to the app Store

Saved Image in document directory and save path in coredata not able to fetch the image file iOS swift