0

So I have a geometry proxy that wraps a custom UITextField that I made. The only problem with the text field, is if I type in a long string, the width of the textfield gets larger to accommodate the content size. I figured the best way (I could be wrong) to deal with this is to wrap it in a geometryreader and then set the max width of the textfield as the proxy's width: Only problem is I don't know how to access the proxy's width:

HStack {
    GeometryReader { proxy in
        TextFieldAlternate(text: self.$bindingVariable)
            .padding(.top, 10)
            .padding(.leading, 15)
            .padding(.bottom, 10)
            .cornerRadius(10)
            .frame(maxWidth: proxy.bounds.width)
    }
}.padding(.horizontal)
 .padding(.top, 65)

Ideally, this would like exactly like it does when the "TextFieldAlternate" is just a normal TextField. Am I thinking about this in the correct way? Because my logic was the GeometryReader will have the same dimensions as that HStack and so if I set the maxWidth of the textfield to be the same as the HStack, it won't ever get any bigger, right?

nickcoding
  • 305
  • 8
  • 35

0 Answers0