我想在我的主窗口顶部显示一个简单的标签栏。这是我使用的代码:
UIView* tabBar = [[UIView alloc] init];
tabBar.backgroundColor = [UIColor redColor];
tabBar.translatesAutoresizingMaskIntoConstraints = false;
[self.view addConstraint:
[NSLayoutConstraint constraintWithItem:tabBar
attribute:NSLayoutAttributeWidth
relatedBy:NSLayoutRelationEqual
toItem:self.view
attribute:NSLayoutAttributeWidth
multiplier:0
constant:0]];
[self.view addConstraint:
[NSLayoutConstraint constraintWithItem:tabBar
attribute:NSLayoutAttributeTop
relatedBy:NSLayoutRelationEqual
toItem:self.view
attribute:NSLayoutAttributeTop
multiplier:1.0f
constant:0]];
[self.view addConstraint:
[NSLayoutConstraint constraintWithItem:tabBar
attribute:NSLayoutAttributeBottom
relatedBy:NSLayoutRelationEqual
toItem:self.view
attribute:NSLayoutAttributeTop
multiplier:1.0f
constant:40]];
但是标签栏无法显示。我在这里做错了什么?