我这样做是为了从 Storyboard 添加一个子视图,它是来自具有自己的类的 ViewController 的子视图。(TomStatusbarController) ...它在 Storyboard 中设置为 CustomClass。我也使用 Layoutformats 进行约束。这工作正常,但状态栏只是红色,我看不到 UIElements。我收到了很多关于约束警告的信息,但它以前工作过,当我把它作为一个 IBOutlet 时,但我现在必须改变它。
-(void)viewDidLoad {
[super viewDidLoad];
if (self) {
self.tomCaptureStatus = [[TomStatusbarController alloc] initWithFrame:CGRectMake(0, 0, 375, 78)];
self.tomCaptureStatus.layer.bounds = CGRectMake(0, 0, 375, 78);
self.tomCaptureStatus.autoresizingMask = UIViewAutoresizingFlexibleWidth |UIViewAutoresizingFlexibleHeight;
self.view.translatesAutoresizingMaskIntoConstraints = YES;
self.tomCaptureStatus.backgroundColor = [UIColor redColor];
[self.view addSubview:self.tomCaptureStatus];
[self.view superview];
}
}
那么为什么我什么也没看到,期待我的背景色?
汤姆