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