iOS UILabel、UIButton文字竖排显示
2016-01-27 18:30
633 查看
- (void)viewDidLoad {
[super
viewDidLoad];
方法一:
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];
}
转载请注明出处:http://blog.csdn.net/sevenquan
[super
viewDidLoad];
方法一:
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];
}
转载请注明出处:http://blog.csdn.net/sevenquan
相关文章推荐
- Swagger-UI的配置与使用
- MUI - 图片预览(perviewimage)的优化
- 37 sensor kit. Arduino
- 【树】Unique Binary Search Trees
- 96. Unique Binary Search Trees && 95. Unique Binary Search Trees II
- Arduino Garden Controller - Automatic Watering and Data Logging
- Arduino based plant watering system using Soil Moisture Sensors
- 2、vuejs五脏
- hdu1121 Complete the Sequence
- HDU 4836 The Query on the Tree lca || 欧拉序列 || 动态树
- PIR Motion Sensor with Arduino
- 1,安装
- 关于UIView的autoresizingMask属性的研究【转】
- leetcode62-Unique Paths
- iOS-值对象NSValue介绍
- [转]SQL SERVER – Find Most Expensive Queries Using DMV
- 引导界面微场景交互设计与技术实现V2.0
- How to control your dust collection with an Arduino (it's easy)
- Arduino started (video)
- 入门动画篇之UIview动画(一)