I’ve the next scrollview but it surely’s not scrolling. Can somebody please assist?
personal func setupUI() {
let scrollView = UIScrollView()
scrollView.translatesAutoresizingMaskIntoConstraints = false
scrollView.showsHorizontalScrollIndicator = false
scrollView.showsVerticalScrollIndicator = false
view.addSubview(scrollView)
NSLayoutConstraint.activate([
scrollView.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor),
scrollView.leadingAnchor.constraint(equalTo: view.leadingAnchor),
scrollView.trailingAnchor.constraint(equalTo: view.trailingAnchor),
scrollView.bottomAnchor.constraint(equalTo: view.bottomAnchor)
])
let contentView = UIView()
contentView.translatesAutoresizingMaskIntoConstraints = false
scrollView.addSubview(contentView)
NSLayoutConstraint.activate([
contentView.topAnchor.constraint(equalTo: scrollView.topAnchor),
contentView.leadingAnchor.constraint(equalTo: scrollView.leadingAnchor),
contentView.widthAnchor.constraint(equalTo: scrollView.frameLayoutGuide.widthAnchor),
contentView.bottomAnchor.constraint(equalTo: scrollView.bottomAnchor)
])
let closeButton = UIButton(sort: .customized)
closeButton.setBackgroundImage(UIImage(named: "close-x"), for: .regular)
closeButton.addTarget(self, motion: #selector(closeTapped), for: .touchUpInside)
closeButton.translatesAutoresizingMaskIntoConstraints = false
contentView.addSubview(closeButton)
let imageView1 = UIImageView()
imageView1.picture = UIImage(named: "freetrialtop")
imageView1.translatesAutoresizingMaskIntoConstraints = false
contentView.addSubview(imageView1)
let overlayButton = UIButton(sort: .customized)
overlayButton.setImage(UIImage(named: "freetrialbtn"), for: .regular)
overlayButton.translatesAutoresizingMaskIntoConstraints = false
contentView.addSubview(overlayButton)
let titleLabel = UILabel()
titleLabel.textual content = "Strive Take a look at PRO"
titleLabel.font = UIFont(title: "WorkSans-SemiBold", dimension: 28)
titleLabel.textColor = UIColor(pink: 0.15, inexperienced: 0.16, blue: 0.20, alpha: 1.00)
titleLabel.textAlignment = .middle
titleLabel.translatesAutoresizingMaskIntoConstraints = false
contentView.addSubview(titleLabel)
let subtitleLabel = UILabel()
subtitleLabel.textual content = "7 days free, then $89.99/per yr"
subtitleLabel.font = UIFont(title: "WorkSans-Common", dimension: 15)
subtitleLabel.textAlignment = .middle
subtitleLabel.textColor = .grey
subtitleLabel.translatesAutoresizingMaskIntoConstraints = false
contentView.addSubview(subtitleLabel)
let trialLabel = UILabel()
trialLabel.textual content = "How your trial works:"
trialLabel.font = UIFont(title: "WorkSans-SemiBold", dimension: 14)
trialLabel.textAlignment = .left
trialLabel.translatesAutoresizingMaskIntoConstraints = false
contentView.addSubview(trialLabel)
let imageView2 = UIImageView()
imageView2.picture = UIImage(named: "freetrialline")
imageView2.translatesAutoresizingMaskIntoConstraints = false
contentView.addSubview(imageView2)
let priceLabel = UILabel()
priceLabel.textual content = "7 days free, then $89.99/per yr"
priceLabel.font = UIFont(title: "WorkSans-Common", dimension: 14)
priceLabel.textAlignment = .middle
priceLabel.textColor = .grey
priceLabel.translatesAutoresizingMaskIntoConstraints = false
contentView.addSubview(priceLabel)
let weeklyPriceLabel = UILabel()
weeklyPriceLabel.textual content = "Solely $1.73 / week"
weeklyPriceLabel.font = UIFont(title: "WorkSans-SemiBold", dimension: 24)
weeklyPriceLabel.textAlignment = .middle
weeklyPriceLabel.translatesAutoresizingMaskIntoConstraints = false
contentView.addSubview(weeklyPriceLabel)
let subscribeButton = UIButton(sort: .customized)
subscribeButton.setImage(UIImage(named: "freetrialbtn1"), for: .regular)
subscribeButton.translatesAutoresizingMaskIntoConstraints = false
contentView.addSubview(subscribeButton)
let cancelStackView = UIStackView()
cancelStackView.axis = .horizontal
cancelStackView.alignment = .middle
cancelStackView.spacing = 8
cancelStackView.translatesAutoresizingMaskIntoConstraints = false
contentView.addSubview(cancelStackView)
let cancelLabel = UILabel()
cancelLabel.textual content = "Cancel anytime. Safe with App Retailer"
cancelLabel.font = UIFont(title: "Inter-Common", dimension: 14)
cancelLabel.textAlignment = .middle
cancelLabel.textColor = .darkGray
cancelLabel.translatesAutoresizingMaskIntoConstraints = false
contentView.addSubview(cancelLabel)
let cancelImage = UIImageView(picture: UIImage(systemName: "checkmark.protect"))
cancelImage.tintColor = .grey
cancelImage.setContentHuggingPriority(.defaultHigh, for: .horizontal)
cancelImage.setContentCompressionResistancePriority(.required, for: .horizontal)
cancelStackView.addArrangedSubview(cancelImage)
cancelStackView.addArrangedSubview(cancelLabel)
let todayLabel = UILabel()
todayLabel.textual content = "As we speak - Free trial begins"
todayLabel.font = UIFont(title: "WorkSans-SemiBold", dimension: 16)
todayLabel.textAlignment = .left
todayLabel.translatesAutoresizingMaskIntoConstraints = false
contentView.addSubview(todayLabel)
let todayDetailLabel = UILabel()
todayDetailLabel.textual content = "Get pleasure from full entry free for 7 days."
todayDetailLabel.font = UIFont(title: "WorkSans-Common", dimension: 12)
todayDetailLabel.textAlignment = .left
todayDetailLabel.textColor = .grey
todayDetailLabel.translatesAutoresizingMaskIntoConstraints = false
contentView.addSubview(todayDetailLabel)
let reminderLabel = UILabel()
reminderLabel.textual content = "(getFutureDate(daysAhead: 5)) - E mail reminder"
reminderLabel.font = UIFont(title: "WorkSans-SemiBold", dimension: 16)
reminderLabel.textAlignment = .left
reminderLabel.translatesAutoresizingMaskIntoConstraints = false
contentView.addSubview(reminderLabel)
let reminderDetailLabel = UILabel()
reminderDetailLabel.textual content = "We’ll let you understand when your trial is ending."
reminderDetailLabel.font = UIFont(title: "WorkSans-Common", dimension: 12)
reminderDetailLabel.textAlignment = .left
reminderDetailLabel.textColor = .grey
reminderDetailLabel.translatesAutoresizingMaskIntoConstraints = false
contentView.addSubview(reminderDetailLabel)
let memberLabel = UILabel()
memberLabel.textual content = "(getFutureDate(daysAhead: 7)) - Grow to be a member"
memberLabel.font = UIFont(title: "WorkSans-SemiBold", dimension: 16)
memberLabel.textAlignment = .left
memberLabel.translatesAutoresizingMaskIntoConstraints = false
contentView.addSubview(memberLabel)
let memberDetailLabel = UILabel()
memberDetailLabel.textual content = "Your trial ends except canceled. Get pleasure from!"
memberDetailLabel.font = UIFont(title: "WorkSans-Common", dimension: 12)
memberDetailLabel.textAlignment = .left
memberDetailLabel.textColor = .grey
memberDetailLabel.translatesAutoresizingMaskIntoConstraints = false
contentView.addSubview(memberDetailLabel)
NSLayoutConstraint.activate([
imageView1.topAnchor.constraint(equalTo: contentView.topAnchor),
imageView1.leadingAnchor.constraint(equalTo: contentView.leadingAnchor),
imageView1.trailingAnchor.constraint(equalTo: contentView.trailingAnchor),
imageView1.heightAnchor.constraint(equalToConstant: 205),
closeButton.topAnchor.constraint(equalTo: contentView.topAnchor, constant: 10),
closeButton.leadingAnchor.constraint(equalTo: contentView.leadingAnchor, constant: 16),
overlayButton.centerXAnchor.constraint(equalTo: imageView1.centerXAnchor),
overlayButton.topAnchor.constraint(equalTo: contentView.topAnchor, constant: 10),
overlayButton.widthAnchor.constraint(equalToConstant: 243),
overlayButton.heightAnchor.constraint(equalToConstant: 66),
titleLabel.topAnchor.constraint(equalTo: overlayButton.bottomAnchor, constant: 20),
titleLabel.centerXAnchor.constraint(equalTo: contentView.centerXAnchor),
subtitleLabel.topAnchor.constraint(equalTo: titleLabel.bottomAnchor, constant: 5),
subtitleLabel.centerXAnchor.constraint(equalTo: contentView.centerXAnchor),
trialLabel.topAnchor.constraint(equalTo: imageView1.bottomAnchor, constant: 20),
trialLabel.leadingAnchor.constraint(equalTo: contentView.leadingAnchor, constant: 20),
imageView2.topAnchor.constraint(equalTo: trialLabel.bottomAnchor, constant: 25),
imageView2.leadingAnchor.constraint(equalTo: contentView.leadingAnchor, constant: 20),
imageView2.widthAnchor.constraint(equalToConstant: 32),
imageView2.heightAnchor.constraint(equalToConstant: 212),
todayLabel.topAnchor.constraint(equalTo: imageView2.topAnchor),
todayLabel.leadingAnchor.constraint(equalTo: imageView2.trailingAnchor, constant: 10),
todayDetailLabel.topAnchor.constraint(equalTo: todayLabel.bottomAnchor, constant: 5),
todayDetailLabel.leadingAnchor.constraint(equalTo: imageView2.trailingAnchor, constant: 10),
reminderLabel.topAnchor.constraint(equalTo: todayDetailLabel.bottomAnchor, constant: 40),
reminderLabel.leadingAnchor.constraint(equalTo: imageView2.trailingAnchor, constant: 10),
reminderDetailLabel.topAnchor.constraint(equalTo: reminderLabel.bottomAnchor, constant: 5),
reminderDetailLabel.leadingAnchor.constraint(equalTo: imageView2.trailingAnchor, constant: 10),
memberLabel.topAnchor.constraint(equalTo: reminderDetailLabel.bottomAnchor, constant: 40),
memberLabel.leadingAnchor.constraint(equalTo: imageView2.trailingAnchor, constant: 10),
memberDetailLabel.topAnchor.constraint(equalTo: memberLabel.bottomAnchor, constant: 5),
memberDetailLabel.leadingAnchor.constraint(equalTo: imageView2.trailingAnchor, constant: 10),
priceLabel.topAnchor.constraint(equalTo: imageView2.bottomAnchor, constant: 50),
priceLabel.centerXAnchor.constraint(equalTo: contentView.centerXAnchor),
weeklyPriceLabel.topAnchor.constraint(equalTo: priceLabel.bottomAnchor, constant: 5),
weeklyPriceLabel.centerXAnchor.constraint(equalTo: contentView.centerXAnchor),
subscribeButton.topAnchor.constraint(equalTo: weeklyPriceLabel.bottomAnchor, constant: 20),
subscribeButton.centerXAnchor.constraint(equalTo: contentView.centerXAnchor),
subscribeButton.widthAnchor.constraint(equalToConstant: 335),
subscribeButton.heightAnchor.constraint(equalToConstant: 48),
cancelStackView.topAnchor.constraint(equalTo: subscribeButton.bottomAnchor, constant: 10),
cancelStackView.centerXAnchor.constraint(equalTo: contentView.centerXAnchor)
])