Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
UILabel可変テキストを含む 984x728 ピクセルの測定値があります。に収まる最大フォントサイズを計算するにはどうすればよいUILabelですか?
UILabel
必要以上に大きなフォントを作成します(48ポイントがおそらく良いでしょう)。次に、これを使用します。
CGFloat maxFontSize; [string sizeWithFont:font minFontSize:0 actualFontSize:&maxFontSize forWidth:maxWidth lineBreakMode: UILineBreakModeClip];
maxFontSize内に収まる48未満および0より大きい最大サイズを保持しますmaxWidth。
maxFontSize
maxWidth