iOS Question How get StringHeight

Discussion in 'iOS Questions' started by omidaghakhani1368, Mar 14, 2015.

  1. omidaghakhani1368

    omidaghakhani1368 Well-Known Member Licensed User

    Hi
    I try to get string height for set label's height but it is wrong value
    Is there other way to get string height?
     
  2. ilan

    ilan Expert Licensed User

    do you want to get the hight of the view? (LABEL) or the textsize??

    both you will need to do in (or after) Sub Page1_Resize (has been called)

    get the font size:

    Code:
    Dim fontsize As Int = lbl.Font.Size
    get label size:

    Code:
    Dim lblsize As Float = lbl.Height
     
  3. omidaghakhani1368

    omidaghakhani1368 Well-Known Member Licensed User

    I want to get label height according to label text for add to scrollview
     
  4. ilan

    ilan Expert Licensed User

    is the text size changing in your code?
     
  5. omidaghakhani1368

    omidaghakhani1368 Well-Known Member Licensed User

    yes,i change textsize then font name and get height
     
  6. ilan

    ilan Expert Licensed User

    so if in the first start you have the font size and the label size that are correct and after changing you only need to change the label height so the font will fit inside
    then change the same % as you change to the font size

    like if font size is 18 and label height is 40 then if you change font size to 20 then this is (100/18 * 20 = 111.11 so 11.11% bigger) now add the same to your label height
    40*1.11 = 44.44

    (just a thought... :), not sure it will do it but it worth a try..)
     
  7. omidaghakhani1368

    omidaghakhani1368 Well-Known Member Licensed User

    :)
    Thank you for your guide.
    I try it
     
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