ios - How to adjust UILabel font size to fit the fixed Rectangle (for iOS7 +)? -
i know question has been asked many times , have seen of solutions like
how adjust font size of label fit rectangle?
how calculate actual font point size in ios 7 (not bounding rectangle)?
nsstring sizewithfont: alternative in ios7
what want want adjust font size in given rect word wrapping technique. posts mentioned above somehow adjust font size none of them using word wrapping technique. let say, have label
uilabel *templabel = [[uilabel alloc] initwithframe:cgrectmake(10, 10, 60, 25)]; \\60px width templabel.text = @"internationalisation"; templabel.numberoflines = 2;
now should wrap text in 1 line (within 60 px) minimum possible font. keeps text in 2 lines bit bigger font , text breaks "internationali" in first line , "sation" in second. how can apply word wrapping in it.
templabel.adjustsfontsizetofitwidth = yes;
does not seem work 2 or more lines and
cgsize size = [self sizewithfont:font minfontsize:minfontsize actualfontsize:&actualfontsize forwidth:maxwidth linebreakmode:self.linebreakmode];
is deprecated in ios7+ how can resolve issue. please help. important me.
like olesko said, use "sizewithattributes" on ios > 7, it's better, because works on line spacing, paragraphe style, text style....
Comments
Post a Comment