我需要以编程方式创建一个带有 UILabel 子视图的 UIView,因为它比 IB 动画效果更好。我无法让 UIView 识别 UILabel。这是我来自 viewDidLoad 的代码:
UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(764, 94, 200, 100)];
[label setText:@"Hello"];
[label setTextColor:[UIColor redColor]];
[label setBackgroundColor:[UIColor clearColor]];
UIView *hintView = [[UIView alloc]initWithFrame:CGRectMake(764, 94, 240, 198)];
[hintView setBackgroundColor:[UIColor colorWithRed:(34/255.f) green:(59/255.f) blue:(27/255.f) alpha:(255/255.f)]];
[hintView addSubview:label];
[self.view addSubview:hintView];
NSLog(@"subview %@", hintView.subviews);
谢谢