UILabel 文字不会显示 [英] UILabel text won't display

查看:51
本文介绍了UILabel 文字不会显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用 UILabels 构建的 iOS 应用程序中遇到了问题:尽管对它们进行了初始化,但我编写的文本不会显示出来,而且我对我应该做的事情束手无策.

I'm having trouble in an iOS app I'm building with UILabels: despite initializing them the text I programmed won't show up and I'm at wits' end about what I should do.

例如,这是我遇到此问题的应用程序屏幕之一:

For example, this is one of the app's screens in which I have this problem:

欢迎.m

@interface Welcome()

@end

@implementation Welcome

-(void) viewdidLoad{
    [super viewDidLoad];
    UILabel * label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 140, 47)];
    [self.view addSubview: label];
    label.text = @"Benvinguts a la pràctica de iOS I";
    label.numberOfLines = 4;

}

-(IBAction) buttonPressed: (id) sender
{

   [self performSegueWithIdentifier:@"Tutorial1" sender:self];
}


@end

你能帮我解决这个问题吗?

Could you help me out in fixing this?

推荐答案

需要添加一个textColor:

You need to add a textColor:

   UILabel * label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 140, 47)];
    [self.view addSubview: label];
    label.text = @"Benvinguts a la pràctica de iOS I";
    label.numberOfLines = 4;
    label.textColor = [UIColor blackColor];

这篇关于UILabel 文字不会显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆