I’ve the next code
let scrollView = UIScrollView()
scrollView.translatesAutoresizingMaskIntoConstraints = false
scrollView.showsVerticalScrollIndicator = false
scrollView.showsHorizontalScrollIndicator = false
scrollView.bounces = true
self.view.addSubview(scrollView)
NSLayoutConstraint.activate([
scrollView.leadingAnchor.constraint(equalTo: self.view.leadingAnchor),
scrollView.trailingAnchor.constraint(equalTo: self.view.trailingAnchor),
scrollView.topAnchor.constraint(equalTo: progressView.bottomAnchor, constant: 20),
scrollView.bottomAnchor.constraint(equalTo: self.view.bottomAnchor)
])
// Create the UILabels, UIImageView, and UIButton
let titleLabel = UILabel()
titleLabel.textual content = "Your Intelligence Sorts"
titleLabel.font = UIFont(title: "Inter-Daring", measurement: 20)
titleLabel.textAlignment = .middle
titleLabel.translatesAutoresizingMaskIntoConstraints = false
scrollView.addSubview(titleLabel)
// Set constraints for the stackView
NSLayoutConstraint.activate([
titleLabel.topAnchor.constraint(equalTo: scrollView.safeAreaLayoutGuide.topAnchor, constant: 20),
titleLabel.leadingAnchor.constraint(equalTo: scrollView.leadingAnchor, constant: 20),
titleLabel.trailingAnchor.constraint(equalTo: scrollView.trailingAnchor, constant: -20),
titleLabel.heightAnchor.constraint(equalToConstant: 30)
])
// Create the UILabels, UIImageView, and UIButton
let descriptionLbl = UILabel()
descriptionLbl.textual content = "Various kinds of intelligence spotlight the varied methods individuals assume, remedy issues, and work together with the world round them."
descriptionLbl.font = UIFont(title: "Inter-Common", measurement: 14)
descriptionLbl.textAlignment = .left
descriptionLbl.numberOfLines = 0
descriptionLbl.translatesAutoresizingMaskIntoConstraints = false
scrollView.addSubview(descriptionLbl)
// Set constraints for the stackView
NSLayoutConstraint.activate([
descriptionLbl.topAnchor.constraint(equalTo: titleLabel.bottomAnchor, constant: 20),
descriptionLbl.leadingAnchor.constraint(equalTo: scrollView.leadingAnchor, constant: 20),
descriptionLbl.widthAnchor.constraint(equalToConstant: 350),
descriptionLbl.heightAnchor.constraint(equalToConstant: 60)
])
var previousProgressView : UIProgressView? = nil
let previousTitleHeight: CGFloat = 30
let progressViewHeight: CGFloat = 20
let labelHeight: CGFloat = 20
let verticalSpacing: CGFloat = 20
var n = 0;
for (key, worth) in totalTypes {
let typeLabel = UILabel()
typeLabel.textual content = key
typeLabel.font = UIFont(title: "Inter-Daring", measurement: 16)
typeLabel.textAlignment = .left
typeLabel.translatesAutoresizingMaskIntoConstraints = false
let iprogressView = UIProgressView(progressViewStyle: .bar)
iprogressView.trackTintColor = UIColor(pink: 0.07, inexperienced: 0.45, blue: 0.87, alpha: 0.1)
iprogressView.tintColor = UIColor(pink: 0.07, inexperienced: 0.45, blue: 0.87, alpha: 1.00)
iprogressView.layer.cornerRadius = 4
iprogressView.clipsToBounds = true
iprogressView.setProgress(Float(userTypes[key] ?? 0) / Float(worth), animated: true)
iprogressView.translatesAutoresizingMaskIntoConstraints = false
let rework : CGAffineTransform = CGAffineTransform(scaleX: 1.0, y: 3.0)
iprogressView.rework = rework
let progressLabel = UILabel()
let progressValue = spherical(((Float(userTypes[key] ?? 0) / Float(worth)) * 100) * 100) / 100
progressLabel.textual content = "(progressValue) %"
progressLabel.translatesAutoresizingMaskIntoConstraints = false
progressLabel.font = UIFont(title: "Inter-Common", measurement: 16)
scrollView.addSubview(typeLabel)
scrollView.addSubview(iprogressView)
scrollView.addSubview(progressLabel)
NSLayoutConstraint.activate([
typeLabel.topAnchor.constraint(equalTo: previousProgressView?.bottomAnchor ?? descriptionLbl.bottomAnchor, constant: previousProgressView == nil ? verticalSpacing : verticalSpacing),
typeLabel.leadingAnchor.constraint(equalTo: scrollView.leadingAnchor, constant: 20),
typeLabel.trailingAnchor.constraint(equalTo: scrollView.trailingAnchor, constant: -20),
typeLabel.heightAnchor.constraint(equalToConstant: 20),
iprogressView.topAnchor.constraint(equalTo: typeLabel.bottomAnchor, constant: 20),
iprogressView.leadingAnchor.constraint(equalTo: scrollView.leadingAnchor, constant: 20),
iprogressView.widthAnchor.constraint(equalToConstant: 200),
iprogressView.heightAnchor.constraint(equalToConstant: 3),
// Position the label next to the progressView
progressLabel.leadingAnchor.constraint(equalTo: iprogressView.trailingAnchor, constant: 10),
progressLabel.centerYAnchor.constraint(equalTo: iprogressView.centerYAnchor)
])
// Replace the previousProgressView reference
previousProgressView = iprogressView
n += 1
}
// Set the content material measurement of the scrollView
let totalContentHeight = (CGFloat(totalTypes.rely) * (labelHeight + progressViewHeight + verticalSpacing + CGFloat(100))) + verticalSpacing + CGFloat(2000)
scrollView.contentSize = CGSize(width: self.view.body.width, top: totalContentHeight)
The issue is the scrollview will not scroll regardless that I set the content material measurement. Can somebody please assist?

