如何在 constraintsWithVisualFormat 中同时添加水平和垂直视觉格式?只有水平的。我想添加 V:|-50-[leftButton] 和 V:|-50-[rightButton] 到它。怎么做?创建另一个 NSLayoutConstraint?
- (void)viewDidLoad
{
[super viewDidLoad];
UIButton *leftButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[leftButton setTitle:@"Left" forState:UIControlStateNormal];
[leftButton setTranslatesAutoresizingMaskIntoConstraints:NO];
[self.view addSubview:leftButton];
UIButton *rightButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[rightButton setTitle:@"Right" forState:UIControlStateNormal];
[rightButton setTranslatesAutoresizingMaskIntoConstraints:NO];
[self.view addSubview:rightButton];
NSArray *layoutConstraints = [NSLayoutConstraint constraintsWithVisualFormat:@"H:|-50-[leftButton(>=80)]-50-[rightButton(>=80)]" options:0 metrics:nil views:NSDictionaryOfVariableBindings(leftButton, rightButton)];
[self.view addConstraints:layoutConstraints];
}