0

I tried using sizeWithAtrributes but it just breaks, not sure what I'm doing wrong this is the error that come up sizeWithFont:minFontSize:actualFont:forWidth:lineBreakMode: is deprecated in 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];
}
Gunaseelan
  • 2,494
  • 5
  • 36
  • 43
kryptics
  • 13
  • 5

1 Answers1

0

I use this instead:

CGRect r = [str boundingRectWithSize:CGSizeMake(sizeLimit.width, CGFLOAT_MAX)
                             options:NSStringDrawingUsesLineFragmentOrigin|NSStringDrawingUsesFontLeading
                          attributes:@{NSFontAttributeName:realLabel.font}
                             context:nil];
r = CGRectIntegral(r).size;
Nicolas Buquet
  • 3,880
  • 28
  • 28