计算字符串的高度
swift的原生方法名,基本跟OC一致
OC旧方法,用了会警告
CGSize size = [self.message sizeWithFont:[UIFont systemFontOfSize:17] constrainedToSize:CGSizeMake(200,9999)];
OC新方法
CGSize size = [topicModel.content boundingRectWithSize:CGSizeMake(278,MAXFLOAT) options: NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:15]} context:nil].size;
swift
boundingRectWithSize(size: CGSize,options: NSStringDrawingOptions,attributes: [NSObject : AnyObject]!,context: NSStringDrawingContext!) -> CGRect
例
var size = CGRect();
var size2 = CGSize();
size = string.boundingRectWithSize(size2,options: NSStringDrawingOptions.UsesFontLeading,attributes: nil,context: nil);