添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
相关文章推荐
狂野的水煮鱼  ·  angular - ThingsBoard ...·  1 年前    · 
爱运动的木瓜  ·  ssis error visual ...·  1 年前    · 
无邪的四季豆  ·  python3 ...·  1 年前    · 
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view, typically from a nib. override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() // Dispose of any resources that can be recreated. @IBAction func buttonAction(_ sender: AnyObject) { let newView = UIView(frame: CGRect(x: 0, y: 0, width: 240, height: 128)) newView.heightAnchor.constraint(equalToConstant: 128) newView.widthAnchor.constraint(equalToConstant: 240) newView.backgroundColor = UIColor.green stackOutlet.addArrangedSubview(newView) stackOutlet.heightAnchor.constraint(equalToConstant: stackOutlet.frame.size.height + 128) print(stackOutlet.subviews.count)

The number of subviews is increasing, but nothing is changing on the screen. I suspect that my StackView doesnt resize properly right ?

Nevermind I found a solution :

newView.widthAnchor.constraint(equalToConstant: 240).isActive = true
newView.heightAnchor.constraint(equalToConstant: 128).isActive = true

You need the .isActive = true

i've been struggling with resizing a stack view in my UITableCell, thanks to you I can now resize it. – GyroCocoa Oct 3, 2017 at 19:57

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.