我目前有一个UILabel:
factLabel = [[UILabel alloc] initWithFrame:CGRectMake(20, 100, 280, 100)];
factLabel.text = @"some text some text some text some text";
factLabel.backgroundColor = [UIColor clearColor];
factLabel.lineBreakMode = UILineBreakModeWordWrap;
factLabel.numberOfLines = 10;
[self.view addSubview:factLabel];
在我的iOS应用程序的整个生命周期中,factLabel获取一堆不同的值.有些有多个句子,有些只有5或6个单词.
如何设置,UILabel以便字体大小更改,以便文本始终适合我定义的范围?
我正在尝试设置UILabel的字体大小.无论我放什么价值,文字大小似乎都没有改变.这是我正在使用的代码.
[self setTitleLabel:[[UILabel alloc] initWithFrame:CGRectMake(320.0,0.0,428.0,50.0)]];
[[self contentView] addSubview:[self titleLabel]];
UIColor *titlebg = [UIColor clearColor];
[[self titleLabel] setBackgroundColor:titlebg];
[[self titleLabel] setTextColor:[UIColor blackColor]];
[[self titleLabel] setFont:[UIFont fontWithName:@"System" size:36]];
我看过很多改变UILabel大小的例子.
这是我想要做的:更改字体大小,以便文本在新高度内尽可能大.
有线索吗?