UILabel显示问题

时间:2011-05-12 10:00:43

标签: iphone

enter image description here

在上图中显示......

我需要在UILabel中显示完整的数据。

这是UILabel的对齐问题

UILabel *lable=[[UILabel alloc]init];
lable.frame=CGRectMake(350, 25, 50, 50);
[lable setTextColor:[UIColor whiteColor]];
[lable setBackgroundColor:[UIColor clearColor]];
[lable setText:@"Leveraged Commentary & Data"];

我需要在lable @“Leveraged Commentary& Data”上显示已完成的setText;

请帮帮我。

提前致谢

4 个答案:

答案 0 :(得分:3)

UILabel *lable=[[UILabel alloc]init];

lable.frame=CGRectMake(350, 25, increase this value , 50);
[lable setTextColor:[UIColor whiteColor]];
[lable setBackgroundColor:[UIColor clearColor]];
[lable setText:@"Leveraged Commentary & Data"];

您需要增加标签的宽度

答案 1 :(得分:1)

您可以做两件事来显示完整文本。

1)增加UILabel的宽度。

2)增加高度并设置无行数。

答案 2 :(得分:0)

可以增加标签宽度吗?标签太小而无法显示文本。请尝试此

lable.frame=CGRectMake(350, 25, 350, 50);
lable.adjustsFontSizeToFitWidth = NO;

答案 3 :(得分:0)

使您的标签的框架更宽,根据您的代码,它只有50分。 NSString有一个方法sizeWithFont:forWidth:lineBreakMode:,可以让你获得文本的尺寸。

这是一个类似question的答案。