两行标签 [英] Label in two rows
本文介绍了两行标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的应用程序中有2行标签,但第一行中的最后一个单词分为两行.例如,如果最后一个单词是"home",则我在第一行中包含h,在第二行中包含ome.我该如何解决?
I have a label in 2 lines in my app but the last word in the first line breaks in two rows. For example if last word is 'home' I have h in the first line and ome in the second. How can I fix that?
更新:
通过IB并使用代码自动换行,但没有成功.
Put over IB and in code word wrap but without success.
代码部分:
...
cell.leftArticleTitleLabel.lineBreakMode = NSLineBreakByWordWrapping;
[cell.leftArticleTitleLabel setLineBreakMode:TRUE];
cell.leftArticleTitleView.frame = CGRectMake(cell.leftArticleTitleView.frame.origin.x, 40, 159, 40);
cell.leftArticleTitleLabel.frame = CGRectMake(cell.leftArticleTitleLabel.frame.origin.x, cell.leftArticleTitleLabel.frame.origin.y, 149, 40);
...
更新2 :已解决
我应该先把"setLineBreakMode:TRUE":-)
I should put "setLineBreakMode:TRUE" first :-)
...
[cell.leftArticleTitleLabel setLineBreakMode:TRUE];
cell.leftArticleTitleLabel.lineBreakMode = NSLineBreakByWordWrapping;
cell.leftArticleTitleView.frame = CGRectMake(cell.leftArticleTitleView.frame.origin.x, 40, 159, 40);
cell.leftArticleTitleLabel.frame = CGRectMake(cell.leftArticleTitleLabel.frame.origin.x, cell.leftArticleTitleLabel.frame.origin.y, 149, 40);
...
推荐答案
将标签的换行模式更改为自动换行.
change the line break mode of the label to word wrapping.
图形上:
使用代码:
label.lineBreakMode = NSLineBreakByWordWrapping;
这篇关于两行标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文