我想从代码(以编程方式)动态地将 UILabel 控件添加到我的应用程序中,请帮助我
问问题
2281 次
1 回答
4
您可以在其中一种视图控制器方法中执行以下操作:
UILabel *myLabel = [[UILabel alloc] initWithFrame:CGRectMake(...)]; // Create UILabel
myLabel.tag = someTag; // set label's tag to access this label in future via [view viewWithTag:someTag];
... // set label's properties like text, background and text color, font size etc (e.g. myLabel.textColor = [UIColor redColor];)
[view addSubView:myLabel]; // add label to your view
[myLabel release]; // view owns the label now so we can release it
于 2009-10-21T06:59:09.993 回答