Latest1.0.0
Homepagehttps://github.com/interchen/ICPageViewController
LicenseMIT
Platformsios 8.0
Authors

ICPageViewController Build Status

A container which easy to add children viewcontrollers and support horizontal scroll.

Preview

screenshot

Create ICPageViewController instance

let pageViewController = ICPageViewController()

override func viewDidLoad() {
    super.viewDidLoad()
    // Do any additional setup after loading the view, typically from a nib.

    pageViewController.pageViewDelegate = self
    self.addChildViewController(pageViewController)
    self.view.addSubview(pageViewController.view)
    pageViewController.didMove(toParentViewController: self)
}

override func viewDidLayoutSubviews() {
    pageViewController.view.frame = self.view.bounds
}

Implement ICPageViewControllerDelegate

func numberOfItems(in pageViewController: ICPageViewController) -> Int {
    return 10
}

func pageViewController(_ pageViewController: ICPageViewController, viewControllerForItemAt index: Int) -> UIViewController {
    let viewController = self.storyboard?.instantiateViewController(withIdentifier: "demoViewController") as? SubViewController
    viewController?.label = "sub viewcontroller (index)"
    switch index {
    case 0:
        viewController?.view.backgroundColor = .blue

    case 1:
        viewController?.view.backgroundColor = .red

    case 2:
        viewController?.view.backgroundColor = .gray

    default:
        viewController?.view.backgroundColor = .white
    }
    return viewController!
}

Cocoapods

pod 'ICPageViewController'

Don’t forget to star if you think this is helpful.

Latest podspec

{
    "name": "ICPageViewController",
    "version": "1.0.0",
    "summary": "A container which easy to add children viewcontrollers and support horizontal scrolling.",
    "description": "With few lines code, you can create a ViewController contains multi children ViewControllers,nand make them horizontal scrolling.",
    "homepage": "https://github.com/interchen/ICPageViewController",
    "license": "MIT",
    "authors": {
        "Chen Yanjun": "[email protected]"
    },
    "platforms": {
        "ios": "8.0"
    },
    "source": {
        "git": "https://github.com/interchen/ICPageViewController.git",
        "tag": "1.0.0"
    },
    "source_files": "ICPageViewController/ICPageViewController/*.{swift}",
    "pushed_with_swift_version": "4.0"
}

Pin It on Pinterest

Share This