2015-05-11 29 views
0

我嘗試使用sizeWithAtrributes,但它只是打破了,不知道我做錯了這是拿出sizeWithFont:minFontSize:actualFont:forWidth:lineBreakMode:被棄用iOS7錯誤:sizeWithFont棄用ERROR,如何解決?

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]; 
} 
+0

使用新的方法,http://stackoverflow.com/questions/18897896/replacement-for-deprecated-sizewithfont-in-ios-7 – ToothlessRebel

回答

0

我用這個來代替:

CGRect r = [str boundingRectWithSize:CGSizeMake(sizeLimit.width, CGFLOAT_MAX) 
          options:NSStringDrawingUsesLineFragmentOrigin|NSStringDrawingUsesFontLeading 
          attributes:@{NSFontAttributeName:realLabel.font} 
          context:nil]; 
r = CGRectIntegral(r).size; 
相關問題