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.
我有一个UILabel984x728 像素的可变文本。如何计算适合的最大字体大小UILabel?
UILabel
创建一个比你想要的更大的字体(48 点可能很好)。然后使用这个:
CGFloat maxFontSize; [string sizeWithFont:font minFontSize:0 actualFontSize:&maxFontSize forWidth:maxWidth lineBreakMode: UILineBreakModeClip];
maxFontSize将容纳小于 48 且大于 0 的最大尺寸,以适合maxWidth.
maxFontSize
maxWidth