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

"Value of type UITextField has no member titleLabel" #215

Closed antonmartinsson closed 6 years ago

antonmartinsson commented 6 years ago

Hi,

I was looking for a way to keep placeholder text centered when it's floating above the field (during user input). I came across this discussion (https://github.com/Skyscanner/SkyFloatingLabelTextField/issues/68) and thought that would solve my problem. Unfortunately, this was not the case. When I try to access "titleLabel" and adjust its textAlignment property, XCode tells me that "Value of type UITextField has no member titleLabel".

skarmavbild 2018-06-16 kl 23 59 12

The code block is currently located in ViewDidLoad, but I've also tried putting it in viewDidAppear, with no luck. It seems I can't access any of the unique properties tied to the SkyFloatingLabelTextField, as I can't even seem to programmatically create one (works via Interface Builder though). Does anybody have an idea of what am I doing wrong?

k0nserv commented 6 years ago

@antonmedstorta Did you figure this out since you closed the issue?

antonmartinsson commented 6 years ago

I did. Maybe I should've commented and said so, sorry. The solution was quite simple in the end, really. As I had previously created the textfield it was linked to the ViewController as a UITextField Outlet, and not as a SkyFloatingLabelTextField. After I re-linked it from the Interface Builder and got all my files in order it found the definition and I was able to change the titleLabel property.

Thanks for checking in!