美文网首页
让 textSize 高度随着字体的多少而改变

让 textSize 高度随着字体的多少而改变

作者: 夏夏的一些事 | 来源:发表于2017-02-21 20:15 被阅读0次

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;

}

相关文章

网友评论

      本文标题:让 textSize 高度随着字体的多少而改变

      本文链接:https://www.haomeiwen.com/subject/hunuwttx.html