we all know NSString method sizeWithFont
[@"abacfe" sizeWithFont:[UIFont systemFontOfSize:11] constrainedToSize:maximumLabelSize lineBreakMode:NSLineBreakByCharWrapping];
deprecated in iOS 7. So here is the replacement of this method.
CGSize maximumLabelSize = CGSizeMake(245, FLT_MAX);
NSStringDrawingOptions options = NSStringDrawingTruncatesLastVisibleLine |
NSStringDrawingUsesLineFragmentOrigin;
NSDictionary *attributDict = @{NSFontAttributeName: [UIFont systemFontOfSize:11]};
CGRect rectsize = [@"abcedef" boundingRectWithSize:maximumLabelSize options:options attributes:attributDict context:nil];
if you want to get the height or widht use
float height=ceilf(rectsize.height);
float width=ceilf(rectsize.width);
0 Comment(s)