iOS Question FloatLabeledEditText problem

Discussion in 'iOS Questions' started by mohammadreza hosseinzadeh, Jul 25, 2018.

  1. mohammadreza hosseinzadeh

    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
    Code:
    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

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

    Erel Administrator Staff Member Licensed User

    This code sets the hint font:
    Code:
    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.
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice