You want your label to scroll with scroll view, then you should not add it on your view. When running your code, you can scroll but the fixed label there is pinned to your view, not on your scroll view
Here is a modified version of your code. For constraint I added padding left, padding top, width and height and it works. My code is
let labelOne: UILabel = { let label = UILabel() label.text = "Scroll Top" label.backgroundColor = .red label.translatesAutoresizingMaskIntoConstraints = false return label }() let labelTwo: UILabel = { let label = UILabel() label.text = "Scroll Bottom" label.backgroundColor = .green label.translatesAutoresizingMaskIntoConstraints = false return label }() override func viewDidLoad() { super.viewDidLoad() let screensize: CGRect = UIScreen.main.bounds let screenWidth = screensize.width let screenHeight = screensize.height var scrollView: UIScrollView! scrollView = UIScrollView(frame: CGRect(x: 0, y: 120, width: screenWidth, height: screenHeight)) scrollView.addSubview(labelTwo) NSLayoutConstraint(item: labelTwo, attribute: .leading, relatedBy: .equal, toItem: scrollView, attribute: .leadingMargin, multiplier: 1, constant: 10).isActive = true NSLayoutConstraint(item: labelTwo, attribute: .width, relatedBy: .equal, toItem: nil, attribute: .notAnAttribute, multiplier: 1, constant: 200).isActive = true NSLayoutConstraint(item: labelTwo, attribute: .top, relatedBy: .equal, toItem: scrollView, attribute: .topMargin, multiplier: 1, constant: 10).isActive = true NSLayoutConstraint(item: labelTwo, attribute: .height, relatedBy: .equal, toItem: nil, attribute: .notAnAttribute, multiplier: 1, constant: 30).isActive = true scrollView.contentSize = CGSize(width: screenWidth, height: 2000) view.addSubview(scrollView) }