計算文字寬度
NSString *content = @"歡迎來到北京";
CGSize size =[content sizeWithAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:14]}];
計算文字高度
NSString *str = @"我愛北京天安門";
CGRect textRect = [str boundingRectWithSize:CGSizeMake(200, 2000) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:15]} context:nil];