I tried to implement it, but my stack looks dynamic, and my application changes orientation from time to time. I have segment control at the end of the view. I also tried to take a walk, but no luck. thanks in advance.
So far I have done:
In the field of view was loaded:
mainStackView.axis = UILayoutConstraintAxis.Vertical mainStackView.spacing = 3 scrollView.frame = self.view.bounds scrollView.addSubview(mainStackView) view.addSubview(scrollView)
Given the layout:
override func viewDidLayoutSubviews() { super.viewDidLayoutSubviews() let top = topLayoutGuide.length let bottom = bottomLayoutGuide.length self.mainStackView.frame = CGRect(x: 0, y: top, width: view.frame.width, height: view.frame.height - top - bottom).insetBy(dx: 10, dy: 10) dispatch_async(dispatch_get_main_queue()) { self.scrollView.frame = self.view.bounds self.scrollView.contentSize = CGSize(width: self.view.bounds.width, height: self.segmentedControl.frame.origin.y + self.segmentedControl.frame.height + 50) } print(scrollView.contentSize) }
shafi source share