0
棄用如何改變SizeWithFont在IOS7
CGSize size=[tempStr sizeWithFont:[UIFont boldSystemFontOfSize:17] constrainedToSize:CGSizeMake(200, 56)];
,使其與IOS7
工作棄用如何改變SizeWithFont在IOS7
CGSize size=[tempStr sizeWithFont:[UIFont boldSystemFontOfSize:17] constrainedToSize:CGSizeMake(200, 56)];
,使其與IOS7
工作你必須使用sizeWithAttributes:
,使用類似:
UIFont *font = [UIFont boldSystemFontOfSize:17.0f];
NSDictionary *attrsDictionary = [NSDictionary dictionaryWithObject:font forKey:NSFontAttributeName];
CGSize size = [tempStrig sizeWithAttributes:attrDictionary];
CGFloat finalHeight;
CGSize constrainedSize = CGSizeMake(requiredWidth,9999);
NSDictionary *attributesDictionary = [NSDictionary dictionaryWithObjectsAndKeys:yourRequiredFont, NSFontAttributeName,nil];
NSMutableAttributedString *string = [[NSMutableAttributedString alloc] initWithString:yourText attributes:attributesDictionary];
CGRect requiredHeight = [string boundingRectWithSize:constrainedSize options:NSStringDrawingUsesLineFragmentOrigin context:nil];
if (requiredHeight.size.width > requiredWidth) {
requiredHeight = CGRectMake(0,0,requiredWidth, requiredHeight.size.height);
}
finalHeight=requiredHeight.size.height;
請訪問http:/ /stackoverflow.com/questions/18897896/replacement-for-deprecated-sizewithfont-in-ios-7 – Yogendra 2014-11-03 05:58:42