https://i-blog.csdnimg.cn/blog_migrate/64fb9604641b018dd677aea40a04286d.pngrequirement/51a5a0756803fa0017000000
UIlabel长度自适应
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0,0,0,0)];//这个frame是初设的,没关系,后面还会重新设置其size。
[label setNumberOfLines:0];
NSString *s = @"abcdefghijklmn";
UIFont *font = [UIFont fontWithName:@"Arial" size:12];
CGSize size = CGSizeMake(320,2000);
CGSize labelsize = [s sizeWithFont:font constrainedToSize:size lineBreakMode:UILineBreakModeWordWrap];
[label setFrame:CGRectMake(0,0, labelsize.width, labelsize.height)];
[self.view addSubView:label];
以上是网上摘抄的 但有个问题如果是英文就会出现显示不全的现象 如何能解决? 求教
丧德拉 | 1038 次查看 | 2 个回答 | 2013-05-29 14:30
共有 2 个回答