sizewithfont的注意

NSString类的sizeWithFont:在ios7以后替换为[nsstring sizewithattribute:@{NSFontAttributeName: [UIFont systemFontOfSize:13]}];

而NSString类的sizeWithFont:constrainedToSize:lineBreakMode:方法在ios7以后替换为

boudingRectWithSize:options:attributes:context方法来代替。

使用如下:

NSDictionary *attribute = @{NSFontAttributeName: [UIFont systemFontOfSize:15]};
CGSize size = [@“相关NSString” boundingRectWithSize:CGSizeMake(width, height) options: NSStringDrawingTruncatesLastVisibleLine | NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading attributes:attribute context:nil].size;

你可能感兴趣的:(sizewithfont的注意)