我必须构建我必须动态添加标签的应用程序,所以你能建议一下吗?
答案 0 :(得分:1)
- (void)addLabelWithText: (NSString*)text toView: (UIView*)view withFrame: (CGRect)frame {
UILabel *label = [[UILabel alloc] initWithFrame: frame];
[label setText: text];
[view addSubview: label];
[label release];
}
在viewController中的其他地方:
[self addLabelWithText: @"Cool Label" toView: [self view] withFrame: CGRectMake(0.0f, 0.0f, 200.0f, 200.0f)];