简体   繁体   中英

Xcode 5 Dynamically Adjust Font Size Multiple Labels

My Xcode 5 project has a label where the User enters a string of numbers. That string is then sent to one of two other labels (either labelA or labelB) by the User pressing one of two buttons. Font size in both labelA and labelB are dynamically resized (if necessary) using:

_labelA.numberOfLines = 1;
_labelA.minimumScaleFactor = 8./_inchesDisplayLabel.font.pointSize;
_labelA.adjustsFontSizeToFitWidth = YES;

and:

_labelB.numberOfLines = 1;
_labelB.minimumScaleFactor = 8./_inchesDisplayLabel.font.pointSize;
_labelB.adjustsFontSizeToFitWidth = YES;

If a string in labelA gets resized to fit within the label, how can the font size in labelB be programmatically resized to match the smaller resized font in labelA? Thanks!

调整labelA的字体大小后,可使用此命令使labelB的字体与labelA的字体匹配:

[labelB setFont:[UIFont fontWithName:labelA.font.fontName size:labelA.font.pointSize]];

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