1
我有stackview在我的银行代码UIStackView不可见
let comment1 = Comment(frame: CGRect(x: 0, y: 0, width: 100, height: 100))
let comment2 = Comment(frame: CGRect(x: 0, y: 100, width: 100, height: 100))
let comment3 = Comment(frame: CGRect(x: 0, y: 200, width: 100, height: 100))
let stackView = UIStackView()
stackView.axis = UILayoutConstraintAxis.vertical
stackView.distribution = UIStackViewDistribution.equalSpacing
stackView.alignment = UIStackViewAlignment.center
stackView.spacing = 16.0
stackView.backgroundColor = .green
stackView.translatesAutoresizingMaskIntoConstraints = false
stackView.addArrangedSubview(comment1)
stackView.addArrangedSubview(comment2)
stackView.addArrangedSubview(comment3)
view.addSubview(stackView)
stackView.topAnchor.constraint(equalTo: view.topAnchor).isActive = true
stackView.bottomAnchor.constraint(equalTo: view.bottomAnchor).isActive = true
stackView.centerXAnchor.constraint(equalTo: view.centerXAnchor).isActive = true
Comment
是UIView.The问题的一个子类是,stackView也不是子视图是visible.Why是什么?
你好,哪里哟üexcatly添加你的筹码看法? –
@MohammadBashirSidani在最后一个'addArrangedSubview' – sakoaskoaso
后面你调用'self.view.addSubview(stackView)'? –