@IBOutlet weak var mainScroll: UIScrollView!
var imageArray = [UIImage]()
override func viewDidLoad() {
super.viewDidLoad()
imageArray = [#imageLiteral(resourceName: "Screen Shot 2018-01-06 at 20.22.59"), #imageLiteral(resourceName: "Screen Shot 2018-01-05 at 15.51.00"), #imageLiteral(resourceName: "Screen Shot 2018-01-05 at 15.50.46")]
for images in 0 ..< imageArray.count {
let imageView = UIImageView() //put our images into imageView
imageView.image = imageArray[images]
//create an imageView for each iamge in imageArray
//and then put the images into imageView one by one
mainScroll.addSubview(imageView) //add this imageView into our mainScroll
let xPosition = self.view.frame.width * CGFloat(images)
//set the starting x for the whole content
imageView.frame = CGRect(x: xPosition, y: 0, width: self.mainScroll.frame.width, height: self.mainScroll.frame.height)
//position our imageView
mainScroll.contentSize.width = mainScroll.frame.width * CGFloat(images + 1)
//calculate the width of our contentSize for mainScroll
view.addSubview(mainScroll)
//and finally, add this scrollView to our mainView
}
}