iOS Question FloatLabeledEditText problem

mohammadreza hosseinzadeh

Member
Licensed User
hi there
i have two problem with this lib
first of all i want to set custom font to this view
i use this method for coloring and setting font
B4X:
Sub SetHintColor(tf As TextField, disabledcolor As Int,enableadcolor As Int,txt As String)
    Dim no As NativeObject = tf
    Dim attr As AttributedString
    attr.Initialize(tf.HintText, tf.Font, enableadcolor)
    '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(enableadcolor))   '<-- Set color when view is focused
        no.SetField("floatingLabelTextColor",no.ColorToUIColor(disabledcolor))    '<-- Set color when view is not focused
 
    Dim s As AttributedString
    s.Initialize(txt, mycustomfont, disabledcolor)
    no.RunMethod("setAttributedPlaceholder:", Array(s))
    End If
End Sub

but this method is set font to inline hint and when im typing some thing and hint goes up the font of it change to default
how can i set font for both situation


my second problem is for multilining
as i know textfield is single line and text view is multi line

and the github source of this view says that it support both of them

https://github.com/jverdi/JVFloatLabeledTextField

This UI component library, which includes both a UITextField and UITextView subclass, aims to improve the user experience by having placeholders transition into floating labels that hover above the fields after they are populated with text.

now how can i set it to multiline
tnx alot for your next replies
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
This code sets the hint font:
B4X:
Sub SetHintColor(tf As TextField, disabledcolor As Int,enableadcolor As Int,txt As String)
   Dim no As NativeObject = tf
   Dim attr As AttributedString
   attr.Initialize(tf.HintText, tf.Font, enableadcolor)
   '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("floatingLabelFont", Font.DEFAULT_ITALIC)
       no.SetField("floatingLabelActiveTextColor",no.ColorToUIColor(enableadcolor))   '<-- Set color when view is focused
       no.SetField("floatingLabelTextColor",no.ColorToUIColor(disabledcolor))    '<-- Set color when view is not focused
       Dim s As AttributedString
       s.Initialize(txt, Font.DEFAULT_ITALIC, disabledcolor)
       no.RunMethod("setAttributedPlaceholder:", Array(s))
   End If
End Sub

It will not work with multiline text.
 
Upvote 0
Top