';sizeWithFont:constrainedToSize:lineBreakMode:';已弃用:在iOS 7.0中首次弃用-使用-BoundingRectiveWithSize:选项:属性:上下文:
有人能帮我修复这个警告吗 “sizeWithFont:constrainedToSize:lineBreakMode:”已弃用:在iOS 7.0中首次弃用-使用-boundingRectWithSize:选项:属性:上下文:';sizeWithFont:constrainedToSize:lineBreakMode:';已弃用:在iOS 7.0中首次弃用-使用-BoundingRectiveWithSize:选项:属性:上下文:,ios,objective-c,xcode7,Ios,Objective C,Xcode7,有人能帮我修复这个警告吗 “sizeWithFont:constrainedToSize:lineBreakMode:”已弃用:在iOS 7.0中首次弃用-使用-boundingRectWithSize:选项:属性:上下文: -(CGFloat)setLableSizeAccordingToText:(NSString*)text andSetX:(CGFloat)x Y:(CGFloat)y{ self.text = text; CGSize maximumLabelSi
-(CGFloat)setLableSizeAccordingToText:(NSString*)text andSetX:(CGFloat)x Y:(CGFloat)y{
self.text = text;
CGSize maximumLabelSize = CGSizeMake(296, FLT_MAX);
CGSize expectedLabelSize = [text sizeWithFont:self.font constrainedToSize:maximumLabelSize lineBreakMode:self.lineBreakMode];
CGRect frame = CGRectMake(x, y, expectedLabelSize.width+lblHorizontalPadding , lblHeight);
self.frame = frame;
return expectedLabelSize.width + lblHorizontalPadding;
}
新的
sizewittributes
与NSParagraphStyle
相结合,应该可以满足您的需要
NSMutableDictionary *attributes = [NSMutableDictionary new];
[attributes setObject:self.font forKey:NSFontAttributeName];
NSMutableParagraphStyle *paragraphStyle = [[NSParagraphStyle defaultParagraphStyle] mutableCopy];
paragraphStyle.lineBreakMode = self.lineBreakMode;
//paragraphStyle.alignment = self.textAlignment; //uncomment this if you need specific text alignment
[attributes setObject:paragraphStyle forKey:NSParagraphStyleAttributeName];
CGSize expectedLabelSize = [text sizeWithAttributes:attributes];
新的
sizewittributes
与NSParagraphStyle
相结合,应该可以满足您的需要
NSMutableDictionary *attributes = [NSMutableDictionary new];
[attributes setObject:self.font forKey:NSFontAttributeName];
NSMutableParagraphStyle *paragraphStyle = [[NSParagraphStyle defaultParagraphStyle] mutableCopy];
paragraphStyle.lineBreakMode = self.lineBreakMode;
//paragraphStyle.alignment = self.textAlignment; //uncomment this if you need specific text alignment
[attributes setObject:paragraphStyle forKey:NSParagraphStyleAttributeName];
CGSize expectedLabelSize = [text sizeWithAttributes:attributes];
新的
sizewittributes
与NSParagraphStyle
相结合,应该可以满足您的需要
NSMutableDictionary *attributes = [NSMutableDictionary new];
[attributes setObject:self.font forKey:NSFontAttributeName];
NSMutableParagraphStyle *paragraphStyle = [[NSParagraphStyle defaultParagraphStyle] mutableCopy];
paragraphStyle.lineBreakMode = self.lineBreakMode;
//paragraphStyle.alignment = self.textAlignment; //uncomment this if you need specific text alignment
[attributes setObject:paragraphStyle forKey:NSParagraphStyleAttributeName];
CGSize expectedLabelSize = [text sizeWithAttributes:attributes];
新的
sizewittributes
与NSParagraphStyle
相结合,应该可以满足您的需要
NSMutableDictionary *attributes = [NSMutableDictionary new];
[attributes setObject:self.font forKey:NSFontAttributeName];
NSMutableParagraphStyle *paragraphStyle = [[NSParagraphStyle defaultParagraphStyle] mutableCopy];
paragraphStyle.lineBreakMode = self.lineBreakMode;
//paragraphStyle.alignment = self.textAlignment; //uncomment this if you need specific text alignment
[attributes setObject:paragraphStyle forKey:NSParagraphStyleAttributeName];
CGSize expectedLabelSize = [text sizeWithAttributes:attributes];
尝试使用此功能
+ (CGSize)DescriptionHeight:(NSString *)str{
CGSize detailSize = [str boundingRectWithSize:CGSizeMake(300, MAXFLOAT)
options:NSStringDrawingUsesLineFragmentOrigin
attributes:@{
NSFontAttributeName:[UIFont fontWithName:@"Cronos Pro" size:14.0f]
}
context:nil].size;
return detailSize;
}
CGSize stringsize = [Your_Str_Value sizeWithAttributes:@{NSFontAttributeName: [UIFont systemFontOfSize:16.0f]}];
YourBtn.frame = CGRectMake(10, 5, stringsize.width, 44);
或者你也可以这样使用
+ (CGSize)DescriptionHeight:(NSString *)str{
CGSize detailSize = [str boundingRectWithSize:CGSizeMake(300, MAXFLOAT)
options:NSStringDrawingUsesLineFragmentOrigin
attributes:@{
NSFontAttributeName:[UIFont fontWithName:@"Cronos Pro" size:14.0f]
}
context:nil].size;
return detailSize;
}
CGSize stringsize = [Your_Str_Value sizeWithAttributes:@{NSFontAttributeName: [UIFont systemFontOfSize:16.0f]}];
YourBtn.frame = CGRectMake(10, 5, stringsize.width, 44);
尝试使用此功能
+ (CGSize)DescriptionHeight:(NSString *)str{
CGSize detailSize = [str boundingRectWithSize:CGSizeMake(300, MAXFLOAT)
options:NSStringDrawingUsesLineFragmentOrigin
attributes:@{
NSFontAttributeName:[UIFont fontWithName:@"Cronos Pro" size:14.0f]
}
context:nil].size;
return detailSize;
}
CGSize stringsize = [Your_Str_Value sizeWithAttributes:@{NSFontAttributeName: [UIFont systemFontOfSize:16.0f]}];
YourBtn.frame = CGRectMake(10, 5, stringsize.width, 44);
或者你也可以这样使用
+ (CGSize)DescriptionHeight:(NSString *)str{
CGSize detailSize = [str boundingRectWithSize:CGSizeMake(300, MAXFLOAT)
options:NSStringDrawingUsesLineFragmentOrigin
attributes:@{
NSFontAttributeName:[UIFont fontWithName:@"Cronos Pro" size:14.0f]
}
context:nil].size;
return detailSize;
}
CGSize stringsize = [Your_Str_Value sizeWithAttributes:@{NSFontAttributeName: [UIFont systemFontOfSize:16.0f]}];
YourBtn.frame = CGRectMake(10, 5, stringsize.width, 44);
尝试使用此功能
+ (CGSize)DescriptionHeight:(NSString *)str{
CGSize detailSize = [str boundingRectWithSize:CGSizeMake(300, MAXFLOAT)
options:NSStringDrawingUsesLineFragmentOrigin
attributes:@{
NSFontAttributeName:[UIFont fontWithName:@"Cronos Pro" size:14.0f]
}
context:nil].size;
return detailSize;
}
CGSize stringsize = [Your_Str_Value sizeWithAttributes:@{NSFontAttributeName: [UIFont systemFontOfSize:16.0f]}];
YourBtn.frame = CGRectMake(10, 5, stringsize.width, 44);
或者你也可以这样使用
+ (CGSize)DescriptionHeight:(NSString *)str{
CGSize detailSize = [str boundingRectWithSize:CGSizeMake(300, MAXFLOAT)
options:NSStringDrawingUsesLineFragmentOrigin
attributes:@{
NSFontAttributeName:[UIFont fontWithName:@"Cronos Pro" size:14.0f]
}
context:nil].size;
return detailSize;
}
CGSize stringsize = [Your_Str_Value sizeWithAttributes:@{NSFontAttributeName: [UIFont systemFontOfSize:16.0f]}];
YourBtn.frame = CGRectMake(10, 5, stringsize.width, 44);
尝试使用此功能
+ (CGSize)DescriptionHeight:(NSString *)str{
CGSize detailSize = [str boundingRectWithSize:CGSizeMake(300, MAXFLOAT)
options:NSStringDrawingUsesLineFragmentOrigin
attributes:@{
NSFontAttributeName:[UIFont fontWithName:@"Cronos Pro" size:14.0f]
}
context:nil].size;
return detailSize;
}
CGSize stringsize = [Your_Str_Value sizeWithAttributes:@{NSFontAttributeName: [UIFont systemFontOfSize:16.0f]}];
YourBtn.frame = CGRectMake(10, 5, stringsize.width, 44);
或者你也可以这样使用
+ (CGSize)DescriptionHeight:(NSString *)str{
CGSize detailSize = [str boundingRectWithSize:CGSizeMake(300, MAXFLOAT)
options:NSStringDrawingUsesLineFragmentOrigin
attributes:@{
NSFontAttributeName:[UIFont fontWithName:@"Cronos Pro" size:14.0f]
}
context:nil].size;
return detailSize;
}
CGSize stringsize = [Your_Str_Value sizeWithAttributes:@{NSFontAttributeName: [UIFont systemFontOfSize:16.0f]}];
YourBtn.frame = CGRectMake(10, 5, stringsize.width, 44);
它对我有用
UILabel *myLabel;
CGSize textSize;
if (!SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"7.0")){
textSize = [myLabel.text sizeWithFont:[myLabel font]];
}else{
textSize = [myLabel.text sizeWithAttributes:[NSDictionary dictionaryWithObject:[myLabel font] forKey:NSFontAttributeName]];
}
它对我有用
UILabel *myLabel;
CGSize textSize;
if (!SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"7.0")){
textSize = [myLabel.text sizeWithFont:[myLabel font]];
}else{
textSize = [myLabel.text sizeWithAttributes:[NSDictionary dictionaryWithObject:[myLabel font] forKey:NSFontAttributeName]];
}
它对我有用
UILabel *myLabel;
CGSize textSize;
if (!SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"7.0")){
textSize = [myLabel.text sizeWithFont:[myLabel font]];
}else{
textSize = [myLabel.text sizeWithAttributes:[NSDictionary dictionaryWithObject:[myLabel font] forKey:NSFontAttributeName]];
}
它对我有用
UILabel *myLabel;
CGSize textSize;
if (!SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"7.0")){
textSize = [myLabel.text sizeWithFont:[myLabel font]];
}else{
textSize = [myLabel.text sizeWithAttributes:[NSDictionary dictionaryWithObject:[myLabel font] forKey:NSFontAttributeName]];
}
也许,因为它被弃用了…也许,因为它被弃用了…也许,因为它被弃用了…也许,因为它被弃用了。。。