我有一个包含4个项目的stackView,我想以编程方式在stackView中设置todayLabel的宽度和高度。我怎样才能做到这一点?我已经尝试了下面的代码,但它没有用。
todayLabel.widthAnchor.constraint(equalToConstant: 50).isActive = true
todayLabel.heightAnchor.constraint(equalToConstant: 100).isActive = true
非常感谢你的帮助,这是我的代码:
let stackView = UIStackView(arrangedSubviews: [todayDate, todayLabel, contentTextView, readMoreLabel])
stackView.axis = .vertical
stackView.distribution = .fillProportionally
stackView.spacing = 5
stackView.anchor(top: viewForImageAndLabel.bottomAnchor, left: safeAreaLayoutGuide.leftAnchor, bottom: shareButton.topAnchor, right: safeAreaLayoutGuide.rightAnchor, paddingTop: 10, paddingLeft: 15, paddingBottom: 10, paddingRight: 15, width: 0, height: 0)
任何人都可以帮我这个吗?