CGSize textSize1 = [self sizeWithText:currentAdress.name andFont:[UIFont systemFontOfSize:14] andMaxSize:CGSizeMake(CJScreenSizes.size.width, MAXFLOAT)];
_nameF = CGRectMake(margincj+5, 5, textSize1.width, textSize1.height);// 让高度随着字体的多少而改变
- (CGSize)sizeWithText:(NSString *)text andFont:(UIFont *)font andMaxSize:(CGSize)maxSize
{
NSDictionary *arrts = @{NSFontAttributeName : font};
return [text boundingRectWithSize:maxSize options:NSStringDrawingUsesLineFragmentOrigin attributes:arrts context:nil].size;
}
网友评论