Ios 将不推荐的sizeWithFont替换为sizeWithAttributes
如何使用SizeWithatAttributes方法生成以下代码:Ios 将不推荐的sizeWithFont替换为sizeWithAttributes,ios,objective-c,sizewithfont,Ios,Objective C,Sizewithfont,如何使用SizeWithatAttributes方法生成以下代码: CGFloat labelWidth = [label.text sizeWithFont:label.font].width; 我需要有标签的宽度 像这样使用 CGFloat labelWidth = [label.text sizeWithAttributes:[NSDictionary dictionaryWithObject:label.font forKey:NSFont
CGFloat labelWidth = [label.text sizeWithFont:label.font].width;
我需要有标签的宽度 像这样使用
CGFloat labelWidth = [label.text sizeWithAttributes:[NSDictionary
dictionaryWithObject:label.font forKey:NSFontAttributeName]].width;
CGSize size = [string sizeWithAttributes:
@{NSFontAttributeName:
[UIFont systemFontOfSize:17.0f]}];
像这样使用
CGSize size = [string sizeWithAttributes:
@{NSFontAttributeName:
[UIFont systemFontOfSize:17.0f]}];
像这样使用
CGSize size = [string sizeWithAttributes:
@{NSFontAttributeName:
[UIFont systemFontOfSize:17.0f]}];
像这样使用
CGSize size = [string sizeWithAttributes:
@{NSFontAttributeName:
[UIFont systemFontOfSize:17.0f]}];
您在CGFloat中获得CGSize,这是错误的哦抱歉我更新了我的答案:)您17.0f的来源是什么?问题不包括特定的字体大小。为什么17.0f是硬编码的?您在CGFloat中获得CGSize,这是错误的。很抱歉,我更新了我的答案:)17.0f的来源是什么?问题不包括特定的字体大小。为什么17.0f是硬编码的?您在CGFloat中获得CGSize,这是错误的。很抱歉,我更新了我的答案:)17.0f的来源是什么?问题不包括特定的字体大小。为什么17.0f是硬编码的?您在CGFloat中获得CGSize,这是错误的。很抱歉,我更新了我的答案:)17.0f的来源是什么?问题不包括特定的字体大小。为什么17.0f是硬编码的?您支持什么iOS版本?您支持什么iOS版本?您支持什么iOS版本?您支持什么iOS版本?您支持什么iOS版本?