У меня есть UIStackView, который состоит из 5 элементов.Я хочу, чтобы центрированный был больше других (как на картинке ниже).
Как мне создать UIStackView ()
stackView.axis = UILayoutConstraintAxis.horizontal
stackView.distribution = UIStackViewDistribution.fillEqually
stackView.alignment = UIStackViewAlignment.bottom
stackView.spacing = 0.0
stackView.addArrangedSubview(supportedServicesView)
stackView.addArrangedSubview(incidentView)
stackView.addArrangedSubview(contactUsView)
stackView.addArrangedSubview(moreView)
stackView.addArrangedSubview(moreView2)
stackView.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(stackView)
stackView.anchor(nil, left: self.view.leftAnchor, bottom: self.view.bottomAnchor, right: self.view.rightAnchor, topConstant: 0, leftConstant: 0, bottomConstant: 90, rightConstant: 0, widthConstant: 0, heightConstant: 0)
Как я создаю свои собственные позиции подвидов UIViews;
override func updateConstraints() {
logoImage.anchor(self.topAnchor, left: self.leftAnchor, bottom: nil, right: self.rightAnchor, topConstant: 0, leftConstant: 0, bottomConstant: 0, rightConstant: 0, widthConstant: 0, heightConstant: 0)
label.anchor(self.logoImage.bottomAnchor, left: self.leftAnchor, bottom: nil, right: self.rightAnchor, topConstant: 10, leftConstant: 0, bottomConstant: 0, rightConstant: 0, widthConstant: 0, heightConstant: 0)
super.updateConstraints()
}
РЕДАКТИРОВАТЬ: когда я добавляю привязку ширины к центрированному виду, она становится больше ширины, но из-за того, что высота одинакова, она не выглядит больше.
contactUsView.widthAnchor.constraint(equalToConstant: self.view.frame.width / 5).isActive = true
РЕДАКТИРОВАТЬ 2: Когда я даю ограничение высоты для любого вида внутри UIStackView, положение Stackviews (только высота) изменяется на значение, которое я дал для привязки высоты Views.