iOS开发 返回字符串的宽高
- (CGFloat)achiveWidthWithHeight:(CGFloat)height Font:(UIFont *)font {
CGSize size = [self boundingRectWithSize:CGSizeMake(MAXFLOAT,
height)
options:NSStringDrawingUsesLineFragmentOrigin
attributes:@{NSFontAttributeName:font}
context:nil].size;
return size.width;
}
- (CGFloat)achiveHeightWithWidth:(CGFloat)width Font:(UIFont *)font {
CGSize size = [self boundingRectWithSize:CGSizeMake(width,
MAXFLOAT)
options:NSStringDrawingUsesLineFragmentOrigin
attributes:@{NSFontAttributeName:font}
context:nil].size;
return size.height;
}