iOS Question [Solved] Trouble with FloatLabeledTextField HintText Color

JordiCP

Expert
Licensed User
Longtime User
I am using THIS snippet to customize the HintText Color and it works correctly, but only when the textfield is empty (i.e, the Hint size and position is that of the main text). But when I type something (and the hint gets smaller and goes to the Top) it remains in its original color, not the chosen one.

What can it be due to? Is it a different field what is shown when the text content is not empty?
 

JordiCP

Expert
Licensed User
Longtime User
Trial and error is your best friend ;P
Perhaps there are other ways, but this worked for me (added the last 2 lines to solve my problem)

B4X:
' Change text hint color in textfield or floatlabeledTextview
Sub SetHintColor(tf As TextField, clr As Int)
    Dim no As NativeObject = tf
    Dim attr As AttributedString
    attr.Initialize(tf.HintText, tf.Font, clr)

    'These two lines also change the color of the hint text when it is placed on the top left (i.e., main text is not null) and the view is a FLoatLabeledTextField
    if tf is FloatLabeledTextField Then
        no.SetField("floatingLabelActiveTextColor",no.ColorToUIColor(clr))   '<-- Set color when view is focused
        no.SetField("floatingLabelTextColor",no.ColorToUIColor(clr))    '<-- Set color when view is not focused
    End If
End Sub
 
Upvote 0
Top