Skip to content

Instantly share code, notes, and snippets.

@farhan-syed
Created September 15, 2017 00:44
Show Gist options
  • Save farhan-syed/95662f0e384a06fe0fc83ddb1bb874a0 to your computer and use it in GitHub Desktop.
Save farhan-syed/95662f0e384a06fe0fc83ddb1bb874a0 to your computer and use it in GitHub Desktop.
func setupImages(_ images: [UIImage]){
for i in 0..<images.count {
let imageView = UIImageView()
imageView.image = images[i]
let xPosition = UIScreen.main.bounds.width * CGFloat(i)
imageView.frame = CGRect(x: xPosition, y: 0, width: scrollView.frame.width, height: scrollView.frame.height)
imageView.contentMode = .scaleAspectFit
scrollView.contentSize.width = scrollView.frame.width * CGFloat(i + 1)
scrollView.addSubview(imageView)
scrollView.delegate = self
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment