使UILabel垂直考上对齐
来源:互联网 发布:c语言必背基础程序 编辑:程序博客网 时间:2024/05/01 11:47
调用sizeToFit方法后,宽度不会变,高度会随内容而改变。
表现的不对,会在最后一行的头部显示省略号,而不是第一行。
1) Set the new text:
myLabel.text = @"Some Text"
2) Set the maximum number of lines to 0 (automatic):
myLabel.numberOfLines = 0
3) Set the frame of the label to the maximum size:
myLabel.frame = CGRectMake(20,20,200,800)
4) Call sizeToFit to reduce the frame size so the contents just fit:
[myLabel sizeToFit]
可用lblPrompt.numberOfLines 来限制高度。
在iOS8、9上测试,如果设置numberOfLines为非0值,则行数不会超过numberOfLines指定的行数。
如果numberOfLines设为0,则高度会超过frame的设置。
一个问题是,此时的.lineBreakMode = NSLineBreakByTruncatingHead表现的不对,会在最后一行的头部显示省略号,而不是第一行。
注意,要在每次给.text设值后都要调用sizeToFit方法。
1) Set the new text:
myLabel.text = @"Some Text"
2) Set the maximum number of lines to 0 (automatic):
myLabel.numberOfLines = 0
3) Set the frame of the label to the maximum size:
myLabel.frame = CGRectMake(20,20,200,800)
4) Call sizeToFit to reduce the frame size so the contents just fit:
[myLabel sizeToFit]
0 0
- 使UILabel垂直考上对齐
- UILabel 垂直方向顶端对齐
- 让UILabel垂直方向顶端对齐
- IOS UILabel垂直顶部,中间,底部对齐
- 让 UILabel 垂直方向顶端对齐的代码
- 让 UILabel 垂直方向顶端对齐的代码
- 分享一个可垂直顶端对齐的UILabel
- UILabel对齐
- 使UILabel垂直靠上对起
- iOS开发之----让UILabel 垂直方向顶端对齐的代码
- IOS开发之----让UILabel 垂直方向顶端对齐的代码
- UILabel 垂直居中问题
- iOS UILabel垂直居中
- UILabel顶端对齐
- UILabel顶端对齐
- UILabel 上下左右对齐
- 让UILabel顶部对齐
- 设置UILabel 两端对齐
- 数组中超过一半的数字
- 为Drupal添加使用jquery框架编写的js文件
- Fatal error: Call-time pass-by-reference has been removed in
- Tomcat服务器配置参考
- 关于系统签名的问题
- 使UILabel垂直考上对齐
- C#6新特性
- JAVA常用多线程知识大全(一)
- js中的函数和执行环境
- 189. Rotate Array
- qt QPalette的应用
- Apache 2.4在windows7系统的安装
- HttpServlet详解
- 易语言 客户组件post发送数据带所有信息