https://github.com/izeni-team/izpagecontroller
A simple alternative to UIPageController
https://github.com/izeni-team/izpagecontroller
Last synced: 3 months ago
JSON representation
A simple alternative to UIPageController
- Host: GitHub
- URL: https://github.com/izeni-team/izpagecontroller
- Owner: izeni-team
- License: mit
- Created: 2016-09-02T02:01:52.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2016-10-04T22:30:42.000Z (over 8 years ago)
- Last Synced: 2025-02-15T15:37:23.473Z (3 months ago)
- Language: Swift
- Size: 24.4 KB
- Stars: 1
- Watchers: 6
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# IZPageController
[](https://travis-ci.org/Taylor/IZPageController)
[](http://cocoapods.org/pods/IZPageController)
[](http://cocoapods.org/pods/IZPageController)
[](http://cocoapods.org/pods/IZPageController)## Requirements
## Installation
IZPageController is available through [CocoaPods](http://cocoapods.org). To install
it, simply add the following line to your Podfile:```ruby
pod "IZPageController"
```## Author
Taylor, [email protected]
## License
IZPageController is available under the MIT license. See the LICENSE file for more info.
## Example
```Swift
import UIKit
import IZPageControllerclass ViewController: IZPageController, IZPageControllerDelegate {
override func viewDidLoad() {
super.viewDidLoad()
delegate = self
}var dualView: Bool {
return scrollView.frame.width >= 320 * 2
}func numberOfViewControllers() -> Int {
return 4
}func viewController(at index: Int) -> UIViewController {
let vc = UIViewController()
switch index {
case 0:
vc.view.backgroundColor = .red
case 1:
vc.view.backgroundColor = .blue
case 2:
vc.view.backgroundColor = .green
case 3:
vc.view.backgroundColor = .yellow
default:
vc.view.backgroundColor = .lightGray
}
vc.view.backgroundColor = vc.view.backgroundColor!.withAlphaComponent(0.5)
return vc
}override func sizeOfViewController() -> CGSize {
if dualView {
return CGSize(width: scrollView.frame.width / 2, height: scrollView.frame.height)
} else {
return scrollView.frame.size
}
}override func updateContentOffsetAfterRotation(previousIndex: Int) {
if dualView {
super.updateContentOffsetAfterRotation(previousIndex: previousIndex - previousIndex % 2)
} else {
super.updateContentOffsetAfterRotation(previousIndex: previousIndex)
}
}
}
```