如何在iOS 7 SDK中获得CGSize
的{{1}}值,只想将以下代码行转换为NSString
。
sizeWithAttributes
答案 0 :(得分:10)
你可以试试这个......
NSDictionary *attributes = @{NSFontAttributeName: [UIFont fontWithName:@"HelveticaNeue" size:14]};
[text sizeWithAttributes:attributes]
或
CGRect rect = [text boundingRectWithSize:CGSizeMake(width, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin attributes:attributes context:nil];