How to adjust font size of label to fit the rectangle?

前端 未结 14 698
独厮守ぢ
独厮守ぢ 2020-11-28 07:00

Yeah, there\'s this cool myLabel.adjustsFontSizeToFitWidth = YES; property. But as soon as the label has two lines or more, it won\'t resize the text to anythin

14条回答
  •  自闭症患者
    2020-11-28 07:07

    All these are interesting solutions to the original problem, however all of them are also missing an important thing: If you solely rely on the familyName to get the next font to test, you're losing the weight information and possibly more advanced attributes like small caps, figure style, etc.

    A better approach is instead of passing the font name around and doing [UIFont fontWithName:someFontName size:someFontSize], passing UIFontDescriptor objects along and then doing [UIFont fontWithDescriptor:someFontDescriptor size:someFontSize].

提交回复
热议问题