import UIKit

class ViewController: UIViewController {
//記錄圖片的張數(shù)
let imagesCount = 5
let kScreenWidth = UIScreen.main.bounds.size.width
let kScreenHeight = UIScreen.main.bounds.size.height
//定義一個scrollView屬性
var scrollView:UIScrollView!
//定義一個pageControl屬性
var pageControl:UIPageControl!
override func viewDidLoad() {
super.viewDidLoad()
self.setupScrollView()
self.setuppageControl()
}
func setupScrollView(){
scrollView = UIScrollView(frame: UIScreen.main.bounds)
scrollView.backgroundColor = #colorLiteral(red: 0.4745098054, green: 0.8392156959, blue: 0.9764705896, alpha: 1)
//設置scrollView的contentSize
scrollView.contentSize = CGSize(width: CGFloat(imagesCount) * kScreenWidth, height: kScreenHeight)
//循環(huán)往scrollView添加圖片
for i in 0..