Skyscanner / SkyFloatingLabelTextField

A beautiful and flexible text field control implementation of "Float Label Pattern". Written in Swift.
Apache License 2.0
4.09k stars 540 forks source link

No support for SwiftUI #313

Closed maxakash closed 3 years ago

maxakash commented 4 years ago

I am using SkyFloatingLabelTextField in SwiftUI . My code is

struct Textfield: UIViewRepresentable {
    func makeUIView(context: Context) -> UITextField {
         let textField = SkyFloatingLabelTextField(frame: CGRect(x: 10, y: 10, width: 200, height: 45))
                             textField.placeholder = "Username"
                             textField.title = "Your full name"

        return textField
    }

    func updateUIView(_ uiView: UITextField, context: Context) {

    }
}

But there is a very large space between the textfield and title. Screenshot 2020-03-22 at 2 26 24 PM

Please suggest any solution @unlobito @richardkeen @ivanz

k0nserv commented 4 years ago

I think this will be due to the layout used, SwiftUI views by default use the whole proposed size to render. I'm still learning SwiftUI myself so I can't really help here. If you find a solution that requires changes to the library we'd be happy to accept a PR

k0nserv commented 4 years ago

So what you probably can do is Textfield().frame(width: nil, height: 45)