UILabel *enterpriseAddress1=[[UILabel alloc]initWithFrame:CGRectMake(90, 130, 180, 20)];
enterpriseAddress1.font = [UIFont systemFontOfSize:13]
enterpriseAddress1.text = [NSString stringWithFormat:@"%@ %@",self.placeText,self.StoreMessage.address];
[scrollView addSubview:enterpriseAddress1];
[enterpriseAddress1 sizeToFit];
注:sizeToFit应放在[scrollView addSubview:enterpriseAddress1]的后面,否则文字无法显示;
本文介绍了在iOS开发中如何使用UILabel的sizeToFit方法来自动调整文字大小以适应Label的显示。示例代码展示了一个创建UILabel并设置字体、文本后,通过调用sizeToFit确保文字能正确显示在ScrollView中的过程。
1092

被折叠的 条评论
为什么被折叠?



