pay attention
setFrame will invalid in stackView
if you add controller like (UIButton,UILabel) in UIStatckView.will let setFrame invalid,usually you will use constraint set width or height
reminderCalorieLabel.frame.size = CGSize(width: 100, height: 100)//invalid
stackVIew prioritize the width of internal views
if you set
stackView.leftAnchor.constraint(equalTo: scrollView.leftAnchor),
stackView.rightAnchor.constraint(equalTo: scrollView.rightAnchor),
//and add a button in stackView,btn add height constrain only,not width,stackView only follow btn width,not be close to scrollVIew
//solution
stackView.widthAnchor.constraint(equalTo: scrollView.widthAnchor)