问题描述
我正在开发一个必须支持iOS6和iOS7的项目。我的问题是它在不同的系统上工作不同。我试图创建UILabel的行数等于2,但是当我设置它的换行模式为NSLineBreakByTruncatingTail它工作不同。
说明(numberOfLines = 2, text = @long teeexxxttt):
iOS7 iOS6
NSLineBreakByWordWrapping
------ ---- ----------
| long | | long |
| teeeexxxtt | | teeeexxxtt |
---------- ----------
NSLineBreakByTruncatingTail
---------- --- -------
| long | |长te ... |
| teeeexx ... | | |
---------- ----------
^ ^
| |
更正不正确 - 只显示一行
如何解决?
问题是iOS6和以前的不会更新多线UILabels与自定义UIFont和NSLineBreakByTruncatingTail,但你可以存档相同的结果通过使用自动调整或自动调整自动布局。I am working on a project that has to support both iOS6 and iOS7. My problem is it works different on different systems. I'm trying to create UILabel with number of lines equal to 2, but when I set it's line break mode to NSLineBreakByTruncatingTail it works different.
Explanation (numberOfLines = 2, text = @"long teeexxxttt"):
iOS7 iOS6
NSLineBreakByWordWrapping
---------- ----------
|long | |long |
|teeeexxxtt| |teeeexxxtt|
---------- ----------
NSLineBreakByTruncatingTail
---------- ----------
|long | |long te...|
|teeeexx...| | |
---------- ----------
^ ^
| |
correct incorrect - shows only one line
How do I fix it?
The problem is iOS6 and prior won't update multiline UILabels with custom UIFont and NSLineBreakByTruncatingTail, but you can archive the same result by using autoresizing or autolayout.
这篇关于UILabel与numberOfLines和lineBreakMode的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!