使用setAdjustsFontSizeToFitWidth的动态字体大小不起作用

时间:2013-03-26 10:06:19

标签: iphone ios objective-c uifont

label中包含UIView。边界设置与UIView相同,因此label应始终与view一样大。

self.label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)];
[self.label setText:@"3"];
[self.label setTextColor:[[UIColor blackColor] colorWithAlphaComponent:0.2f]];
[self.label setFont:[UIFont fontWithName:@"Futura-CondensedExtraBold" size:400]];
[self.label setBackgroundColor:[UIColor clearColor]];
[self.label setTextAlignment:NSTextAlignmentCenter];

[self.label setNumberOfLines:1];
[self.label setMinimumScaleFactor:0.1];
[self.label setAdjustsFontSizeToFitWidth:YES];

[self addSubview:self.label];

正如您所看到的,我将font size设置为400,这是一种很大的方法,希望使用setMinimumScaleFactor将其缩小。但它不适合我。 有什么建议......?

0 个答案:

没有答案
相关问题