UILabel 自动换行--

来源:互联网 发布:网络预警包括 编辑:程序博客网 时间:2024/05/01 03:49
  1. UIView *footerView = [[UIView alloc] initWithFrame:CGRectMake(10, 100, 300, 180)];  
  2.     UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(10, 100, 300, 150)];  
  3.     label.text = @"测试换行测试换行测试换行测试换行测试换行测试换行测试换行测试换行测试换行测试换行测试换行测试换行测试换行测试换行测试换行测试换行测试换行测试换行测试换行测试换行测试换行测试换行测试换行测试换行测试换行测试换行测试换行测试换行测试换行测试换行";  
  4.     //清空背景颜色  
  5.     label.backgroundColor = [UIColor clearColor];  
  6.     //设置字体颜色为白色  
  7.     label.textColor = [UIColor whiteColor];  
  8.     //文字居中显示  
  9.     label.textAlignment = UITextAlignmentCenter;  
  10.     //自动折行设置  
  11.     label.lineBreakMode = UILineBreakModeWordWrap;  
  12.     label.numberOfLines = 0;  
原创粉丝点击