Xcode 4.2 - UILabel Word Wrap [英] Xcode 4.2 - UILabel Word Wrap
问题描述
我知道人们已经在Stack上多次问过这个问题,但通常的答案是更改Lines:0并选择Line Breaks:Word Wrap,这对我来说并不是很有用。
I know people have asked this question a bunch of times alrdy on Stack, but the usual answer of changing "Lines: 0" and selecting "Line Breaks: Word Wrap" just isn't fixing it for me.
我正在使用Xcode 4.2和Storyboard。我在视图控制器上放置了一个UILabel,并将其调整大小以覆盖大部分视图。我已将Lines值更改为0,将Line Breaks值更改为Word Wrap。
I am using Xcode 4.2 with a Storyboard. I have placed a UILabel on a View Controller and resized it to cover most of the View. I have changed "Lines" value to 0 and "Line Breaks" value to Word Wrap.
我在我的字符串中尝试过 \ n
: @这是我的标签文本\ n应该包装。
I have tried \n
in my string: @"This is my label text \n that's supposed to wrap."
任何想法?
编辑:我没有在我的实现文件中声明任何标签的属性,只是在故事板上,所以我尝试了以下......但没有运气; \(字体名称和大小以及对齐工作,但行数和中断模式似乎什么都不做。)
I wasn't declaring any of the label's properties in my implementation file, only on the storyboard, so I have tried the following... But with no luck ;\ (font name and size and alignment work, but number of lines and break mode seem to do nothing.)
lblText.numberOfLines = 0;
lblText.font = [UIFont fontWithName:@Helvetica尺寸:(15.0)];
lblText.lineBreakMode = UILineBreakModeWordWrap;
lblText.textAlignment = UITextAlignmentLeft;
推荐答案
试试这个
[lblText setFrame:CGRectMake(10, 21, 100, 250)];
lblText.text =@"This is my label text \n that's supposed to wrap.";
lblText.numberOfLines = 3;
lblText.font = [UIFont fontWithName:@"Helvetica" size:(15.0)];
lblText.lineBreakMode = UILineBreakModeWordWrap;
lblText.textAlignment = UITextAlignmentLeft;
这篇关于Xcode 4.2 - UILabel Word Wrap的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!