简体   繁体   中英

iOS: How to tell if UILabel's font has been auto-resized?

有没有办法以编程方式确定标签中的文本是否已自动调整大小?

You could probably check the size of the text with the font and compare it to the label's width.

Maybe something like this:

CGSize size = [yourLabel.text sizeWithFont:label.font constrainedToSize:CGSizeMake(100000, yourLabel.frame.size.height)  lineBreakMode:yourLabel.lineBreakMode];

if(size.width > label.frame.size.width)
{
    //you are being autosized
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM