我试着使用sizeWithAtrributes,但它就是坏了,不确定我做错了什么这是出现的错误sizeWithFont:minFontSize:actualFont:forWidth:lineBreakMode:在iOS7中被弃用:
if (theRect.size.width > self.bounds.size.width - rightIconNeeds - leftIconNeeds) {
CGFloat finalSize = realLabel.font.pointSize;
theRect.size = [realLabel.text sizeWithFont:realLabel.font
minFontSize:realLabel.font.pointSize * realLabel.minimumScaleFactor
actualFontSize:&finalSize
forWidth:self.bounds.size.width - rightIconNeeds - leftIconNeeds
lineBreakMode:realLabel.lineBreakMode];
}发布于 2015-05-11 22:57:26
我使用下面的代码:
CGRect r = [str boundingRectWithSize:CGSizeMake(sizeLimit.width, CGFLOAT_MAX)
options:NSStringDrawingUsesLineFragmentOrigin|NSStringDrawingUsesFontLeading
attributes:@{NSFontAttributeName:realLabel.font}
context:nil];
r = CGRectIntegral(r).size;https://stackoverflow.com/questions/30169158
复制相似问题