Use Binding with a TextField SwiftUI

前端 未结 2 1992
無奈伤痛
無奈伤痛 2020-11-29 11:58

I am currently building a page to add player information to a local database. I have a collection of TextFields for each input which is linked to elements in a player struct

2条回答
  •  -上瘾入骨i
    2020-11-29 12:46

    Actually , you can binding manyTypes with TextField:

          @State var weight: Int = 0
          var body: some View {
    
    
           Group{
           Text("\(weight)")
           TextField("Weight", value: $weight, formatter: NumberFormatter())
        }}
    

提交回复
热议问题