UIPageController

2019-04-24  本文已影响0人  79d12e22ec53

UIPageController

import UIKit

class ViewController: UIViewController {





    override func viewDidLoad() {
        super.viewDidLoad()

        self.view.backgroundColor = UIColor.lightGray
        let page = UIPageControl(frame: CGRect(x: 20, y: 100, width: 280, height: 30))
        page.currentPageIndicatorTintColor = UIColor.red
        page.addTarget(self, action: #selector(ViewController.changeNum), for: .valueChanged)
        page.numberOfPages = 8
        self.view.addSubview(page)
    }

    @objc func changeNum(page: UIPageControl) {
        print(page.currentPage)
    }

}
上一篇 下一篇

猜你喜欢

热点阅读