iOS Question How can I use AttributeString to change the font size of a dynamic label?

Discussion in 'iOS Questions' started by davepamn, Mar 17, 2015.

  1. davepamn

    davepamn Active Member Licensed User

    Code:
    Dim tcContract As TableCell=tvContracts.AddSingleLine("")
            tcContract.ShowSelection=
    False
            tcContract.Tag=
    ""
            tcContract.CustomView=Createitem(sContractNumber)

      
    Private Sub Createitem(sValue As StringAs Panel
        
    Dim oPanel As Panel
        
    Dim lblData As Label
        oPanel.Initialize(
    "")
        lblData.Initialize(
    "data")

        
    Dim oValueText As AttributedString
        oValueText.Initialize(sValue,
    Font.CreateNew(30),Colors.Blue)

        lblData.Text=sValue
        lblData.Color=
    Colors.ARGB(255,176,224,230)

        oPanel.Width=
    100%x
        oPanel.Height=tvContracts.RowHeight
        oPanel.AddView(lblData,
    0,0,100%x,tvContracts.RowHeight)

        
    Return(oPanel)

    End Sub
    I can't see a way to change the label size without using designer. If I used designer, how would I layout the label so it does not take up the full screen on the tableview cell.
     
    Last edited: Mar 17, 2015
  2. omidaghakhani1368

    omidaghakhani1368 Well-Known Member Licensed User

    Do you test it?
    I offer you to use richstring module
     
  3. davepamn

    davepamn Active Member Licensed User

    Code:
    I don't need attributeString

    lblData.Font=
    Font.CreateNew(30)
     
  4. davepamn

    davepamn Active Member Licensed User

    Code:
    Private Sub Createitem(tvTableview As TableView, sValue As String,iAlpha As Int, iRed As Int, iGreen As Int, iBlue As Int,iFontSize As Int,iFontColor As Int) As Panel

        
    Dim oPanel As Panel

        
    Dim lblData As Label

        oPanel.Initialize(
    "")

        lblData.Initialize(
    "data")

        lblData.Text=sValue

        lblData.color=
    Colors.ARGB(iAlpha,iRed,iGreen,iBlue)

        lblData.Font=
    Font.CreateNew(iFontSize)

        lblData.TextColor=iFontColor

        oPanel.Width=
    100%x

        oPanel.Height=tvTableView.RowHeight
     
        oPanel.AddView(lblData,
    0,0,100%x,tvTableview.RowHeight)

        
    Return(oPanel)

    End Sub
    Final code
     
  5. Brian Robinson

    Brian Robinson Active Member Licensed User

    Hi, If you are not using the separate color values iRed, iGreen etc, you could just pass the color through as an Int

    Code:
    Private Sub Createitem(tvTableview As TableView, sValue As String,iBackColor as Int,iFontSize As Int,iFontColor As Int) As Panel
    Then set
    Code:
    lblData.color=Colors.ARGB(iBackColor)
    Just a thought.

    Cheers
    Brian
     
    kemanlam likes this.
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