NSObject+bounding.h
import <Foundation/Foundation.h>
import <UIKit/UIKit.h>
@interface NSObject (bounding)
-(CGRect)contentRectWithString:(NSString * )string labelScreenWith:(CGFloat)screenwith AndStringFont:(int)floatnumber;
@end
NSObject+bounding.m里面写
import "NSObject+bounding.h"
@implementation NSObject (bounding)
-(CGRect)contentRectWithString:(NSString *)string labelScreenWith:(CGFloat)screenwith AndStringFont:(int)floatnumber
{
CGRect tmpRect = [string boundingRectWithSize:CGSizeMake(screenwith, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin attributes:[NSDictionary dictionaryWithObjectsAndKeys:SetFont(floatnumber),NSFontAttributeName, nil] context:nil];
return tmpRect;
}
@end