Below code will layout 3 images in a scrollview. The basic steps are:
Note : You need to designed the start coordinate of the Y-Axis for each UIImageView, so that there is no overlapping.
//
// ViewController.swift
// How to create ScrollView
//
// Created by Animesh Banerjee on 30/4/21.
//
import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
view.backgroundColor = .red
let scrollView = UIScrollView(frame: CGRect(x: 10, y: 10, width: view.frame.size.width - 20, height: view.frame.size.height - 20))
scrollView.backgroundColor = .green
view.addSubview(scrollView)
//In the below code, you need to replace the image names with that of yours
let imageView1 = UIImageView(image: UIImage(named: "team1"))
imageView1.sizeToFit()
imageView1.frame = CGRect(x: 10, y: 10, width: Int(view.frame.size.width), height: 300)
let imageView2 = UIImageView(image: UIImage(named: "team2"))
imageView2.sizeToFit()
imageView2.frame = CGRect(x: 10, y: 320, width: Int(view.frame.size.width), height: 300)
let imageView3 = UIImageView(image: UIImage(named: "team3"))
imageView3.sizeToFit()
imageView3.frame = CGRect(x: 10, y: 640, width: Int(view.frame.size.width), height: 300)
scrollView.addSubview(imageView1)
scrollView.addSubview(imageView2)
scrollView.addSubview(imageView3)
scrollView.contentSize = CGSize(width: view.frame.size.width, height: 3000)
}
}