View 如何以编程方式将标签添加到特定的视图控制器?

View 如何以编程方式将标签添加到特定的视图控制器?,view,controller,uilabel,View,Controller,Uilabel,嘿,伙计们,我知道这是一个非常简单的问题,但我被卡住了 到目前为止,我知道要添加标签,您需要: UILabel *myLabel = [[UILabel alloc]initWithFrame:CGRectMake(10, 50, 200, 40)]; [myLabel setBackgroundColor:[UIColor clearColor]]; [myLabel setText:@"Hi Label"]; [[self view] addSubview:myLabel]; 只需用视图控

嘿,伙计们,我知道这是一个非常简单的问题,但我被卡住了

到目前为止,我知道要添加标签,您需要:

UILabel *myLabel = [[UILabel alloc]initWithFrame:CGRectMake(10, 50, 200, 40)];
[myLabel setBackgroundColor:[UIColor clearColor]];
[myLabel setText:@"Hi Label"];
[[self view] addSubview:myLabel];

只需用视图控制器替换
self

UILabel *myLabel = [[UILabel alloc]initWithFrame:CGRectMake(10, 50, 200, 40)];
[myLabel setBackgroundColor:[UIColor clearColor]];
[myLabel setText:@"Hi Label"];
[[viewController view] addSubview:myLabel];