美文网首页
UIlabel高度随文字变化而变化

UIlabel高度随文字变化而变化

作者: andy_tu | 来源:发表于2017-10-07 12:10 被阅读0次

NSString*str = @"我是中国人,我是中国人,我是中国人,我是中国人,我是中国人,我是中国人,我是中国我是中国人人";

UIAlertView*alert = [[UIAlertViewalloc]initWithTitle:NSLocalizedString(@"Are you sure update the device of firmware?",nil)message:nildelegate:nilcancelButtonTitle:nilotherButtonTitles:NSLocalizedString(@"OK",nil),NSLocalizedString(@"Cancel",nil),nil];

alert.tag=10;

alert.delegate=self;

NSDictionary*attributes =@{NSFontAttributeName: [UIFontsystemFontOfSize:12]};

CGSizesize = [strsizeWithAttributes: attributes];

uilabe*label = [[uilabe alloc]initWithFrame:CGRectMake(0,0,240, size.height)andInsets:UIEdgeInsetsMake(0,0,0,0)];

label.font= [UIFontsystemFontOfSize:15];

label.lineBreakMode=NSLineBreakByWordWrapping;

label.numberOfLines=0;

label.textAlignment=NSTextAlignmentLeft;

label.text= str;

CGSizelabelSize = [labelsizeThatFits:CGSizeMake(240.f,MAXFLOAT)];

CGFloatheight =ceil(labelSize.height) +1;

label.frame=CGRectMake(0,0,240, height);

[alertsetValue:labelforKey:@"accessoryView"];

[alertshow];

相关文章

网友评论

      本文标题:UIlabel高度随文字变化而变化

      本文链接:https://www.haomeiwen.com/subject/ahhjyxtx.html