因此,当我需要将我的应用程序升级到更新的 iOS 时,我遇到了 sizeWithFont 命令被贬值的问题。有人可以帮我解决如何用新功能替换它。
这是我的代码:
// Add label if label text was set
if (nil != self.labelText) {
// Get size of label text
CGSize dims = [self.labelText sizeWithFont:self.labelFont];
// Compute label dimensions based on font metrics if size is larger than max then clip the label width
float lHeight = dims.height;
float lWidth;
if (dims.width <= (frame.size.width - 2 * margin)) {
lWidth = dims.width;
}
else {
lWidth = frame.size.width - 4 * margin;
}
// Set label properties
label.font = self.labelFont;
label.adjustsFontSizeToFitWidth = NO;
label.textAlignment = NSTextAlignmentCenter;
label.opaque = NO;
label.backgroundColor = [UIColor clearColor];
label.textColor = [UIColor whiteColor];
label.text = self.labelText;
我如何需要使用新函数来获取标签文本的大小?