iOS Question How get StringHeight

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?
 

ilan

Expert
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?
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:

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

B4X:
Dim lblsize As Float = lbl.Height
 

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..)
 
Top