在文本自适应中,7 .8 系统不一样,对于文本计算方式也不同
+ (CGSize)getTextHeight:(NSString *)text withFont:(UIFont *)font withCGSize:(CGSize)Size{
NSString *inputString = [NSString stringWithFormat:@"%@",text];
CGSize titleSize;
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0) {
titleSize = [inputString boundingRectWithSize:Size options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:font} context:nil].size;
}else{
titleSize = [inputString sizeWithFont:font constrainedToSize:Size lineBreakMode:NSLineBreakByWordWrapping];
}
return titleSize;
}
时间: 2024-10-08 21:05:04