iOS UILabel、UIButton文字竖排显示
来源:互联网 发布:linux设备驱动功能 编辑:程序博客网 时间:2024/06/01 11:23
方法一:
UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(0, 100, 25,200)];
label.text = @"即\n时\n编\n译\n功\n能\n。";
label.numberOfLines = [label.text length];
[self.view addSubview:label];
方法二:
UIFont *font = [UIFont systemFontOfSize:15];
CGSize sizeWord = [@"一" sizeWithFont:font constrainedToSize:CGSizeMake(100,1000.0) lineBreakMode:UILineBreakModeWordWrap];
CGFloat width = sizeWord.width;//一个汉字的宽度
CGSize sizeStr = [@"是一个小巧的脚本语言。" sizeWithFont:font constrainedToSize:CGSizeMake(width, 1000.0) lineBreakMode:UILineBreakModeWordWrap];
CGFloat hight = sizeStr.height;
UILabel *labelTwo = [[UILabel alloc]initWithFrame:CGRectMake(50, 200, width, hight)];
labelTwo.text = @"是一个小巧的脚本语言。";
labelTwo.textColor = [UIColor blackColor];
labelTwo.numberOfLines = 0;
[self.view addSubview:labelTwo];
UIButton *button=[[UIButton alloc] initWithFrame:CGRectMake(100,400, 30, 200)];
button.titleLabel.font=[UIFont fontWithName:@"Helvetica" size:24];
[button setTitle:@"其设计目的是为了嵌入应用程序中" forState:UIControlStateNormal];
[button setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
[button setTitleColor:[UIColor redColor] forState:UIControlStateHighlighted];
button.titleLabel.lineBreakMode = UILineBreakModeWordWrap;//换行模式自动换行
button.titleLabel.numberOfLines = 0;
[self.view addSubview:button];
- iOS UILabel、UIButton文字竖排显示
- iOS UILabel、UIButton文字竖排显示
- iOS UILabel、UIButton文字竖排显示
- iOS UILabel 文字竖排显示
- 纯UILabel实现文字的竖排显示
- 纯UILabel实现文字的竖排显示 记录
- Android竖排显示文字
- 文字竖排显示
- ios 实现文字竖排
- UILabel,UIButton等文字显示的控件大小的自适应
- ios UILabel显示不同颜色的文字
- iOS之UIButton无法显示文字
- UIButton,UILabel文字旋转(倾斜)
- css文字双竖排显示
- 【代码笔记】iOS-竖排文字
- iOS-UI-02 UILabel UIButton
- iOS开发之 UILabel,UIButton
- iOS UILabel UIButton UIImageView使用方法
- DataBinding系列五、XXXBinding
- ios打包ipa的四种实用方法(.app转.ipa)
- git 配置
- 偏差方差分解
- Android秒级编译Freeline的使用(Android Studio)
- iOS UILabel、UIButton文字竖排显示
- Android开发初体验之face++人脸识别加静默拍照
- 解决post乱码的过滤器配置
- 1239: 华科版C语言程序设计教程(第二版)例题6.17
- Android Studio JUnit单元测试
- 第二章 2.3 设计算法
- java DES 加密解密算法及报错 Given final block not properly padded
- UVa 12657:Boxes in a Line
- shell 中的sleep命令