我正在更新一个最初在底部有一个按钮的屏幕。我的任务是使用作为 AutoLayout 包装器的 Masonry 框架呈现两个居中位于底部的按钮。
我想让两个按钮在底部并排居中。这就是我想出的:
这是代码:
- (void)createConstraints {
// Map View
[self.mapView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.left.and.right.equalTo(self);
make.bottom.equalTo(self.mas_centerY).multipliedBy(0.9);
}];
// Information TextView
[self.informationTextView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.mapView.mas_bottom); //.with.offset(kTableViewCellPadding);
make.left.and.right.equalTo(self);
make.bottom.equalTo(self.editSiteButtonBackground.mas_top);//.with.offset(-kTableViewCellPadding);
}];
// Edit Site Button Background
[self.editSiteButtonBackground mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.bottom.and.right.equalTo(self);
make.height.equalTo(@54);
}];
// Add Site Comments Button Background
[self.addSiteCommentsButtonBackground mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.editSiteButton.mas_right);
make.bottom.equalTo(self.editSiteButton);
make.height.equalTo(@54);
}];
// Edit Site Button
[self.editSiteButton mas_makeConstraints:^(MASConstraintMaker *make) {
UIEdgeInsets padding = UIEdgeInsetsMake(10, 10, 10, 10);
make.edges.equalTo(self.editSiteButtonBackground).with.insets(padding).with.priorityHigh();
make.width.lessThanOrEqualTo(@260);
make.centerX.equalTo(self.editSiteButtonBackground);
}];
// Add Site Comments Button
[self.addSiteCommentsButton mas_makeConstraints:^(MASConstraintMaker *make) {
UIEdgeInsets padding = UIEdgeInsetsMake(10, 10, 10, 10);
make.edges.equalTo(self.addSiteCommentsButtonBackground).with.insets(padding).with.priorityHigh();
make.width.lessThanOrEqualTo(@270);
make.top.equalTo(self.addSiteCommentsButton);
make.centerX.equalTo(self.addSiteCommentsButtonBackground);
}];
// Navigation
[self.navigationButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.equalTo(self.mapView).with.offset(-20);
make.bottom.equalTo(self.mapView).with.offset(-20);
}];
}
如何并排显示按钮并在底部居中显示?