iOS Question Set the label height from string

Nicolás Cieri

Active Member
Licensed User
Hi!, I'm trying to set the height of the label from the string..

It almost works, but when it's a long text, it doesn't work well. Also something very strange happens, change the size of the text without me having indicated it.

Any idea? Thanks

Sub getTextHeight(content As String,fo As Font,LbWidth As Float) As Float
    Dim tmpString As String = "大"
    Dim str() As String = Regex.Split(Chr(10),content)
    Dim height As Float
    Dim number As Int
    Dim fontHeight As Float = tmpString.MeasureHeight(fo)
    For Each s As String In str
        number = s.MeasureWidth(fo)/LbWidth + 1
        height = height + number*fontHeight
    Return height + fontHeight
End Sub