https://github.com/mitolog/simpleviewpager
SimpleViewPager is a UI Component like Android's ViewPager
https://github.com/mitolog/simpleviewpager
Last synced: about 2 months ago
JSON representation
SimpleViewPager is a UI Component like Android's ViewPager
- Host: GitHub
- URL: https://github.com/mitolog/simpleviewpager
- Owner: mitolog
- License: mit
- Created: 2015-04-08T19:30:36.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2015-05-22T05:22:38.000Z (about 10 years ago)
- Last Synced: 2025-03-24T08:47:42.433Z (2 months ago)
- Language: Swift
- Size: 164 KB
- Stars: 5
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: ReadMe.md
- License: LICENSE
Awesome Lists containing this project
README
# SimpleViewPager
SimpleViewPager is a UI Component like Android's ViewPager

## Desc
SimpleViewPager is mainly consist of 4 parts:
- MenuView... represents each page, containing scrollView to display title.
- ContentScrollView... displays each view produced by SomeViewController.
- SimpleViewController... manages MenuView above components.
- Main.storyboard... defines layouts of MenuView and ContentScrollView## Spec
- Synchronous menus and content-views while scrolling horizontally
- Uses Storyboard
- Supports rotation
- Easy to customize because of minimum source code (Your contribution will be appriciated)
- Deployment target iOS 7.0## How to use
1. Prepare each page component `MenuElem`.
- name... represents page title.
- className... UIViewController's subclass which holds a view to be pasted on SimpleViewController's scrollView.
- sbName... Storyboard for class above.2. Insert `MenuElem` to your desired position. (array index 0 will be the leftmost)
```swift:SimpleViewController.swift
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
let menus: Array =
[
MenuElem(name: "menu1", className: "SomeViewController", sbName: "Some"),
MenuElem(name: "menu2", className: "SomeViewController", sbName: "Some"),
MenuElem(name: "menu3", className: "SomeViewController", sbName: "Some"),
MenuElem(name: "menu4", className: "SomeViewController", sbName: "Some"),
MenuElem(name: "menu5", className: "SomeViewController", sbName: "Some"),
MenuElem(name: "menu6", className: "SomeViewController", sbName: "Some"),
]self.menuView.setup(menus, delegate:self)
self.setupContentScrollView(menus)
}
```3. You can pass the any parameter to each viewController via `setupContentScrollView(menus: Array)`.
```swift:SimpleViewController.swift
func setupContentScrollView(menus: Array) {
// http://app.coolors.co/e0acd5-3993dd-29e7cd-6a3e37-c7f0bd
let colorPalette = [0xE0ACD5, 0x3993DD, 0x29E7CD, 0x6A3E37, 0xC7F0BD]
var cnt = 0
for menu in menus {
let sb: UIStoryboard = UIStoryboard(name: menu.storyBoardName(), bundle: nil)
let vc = sb.instantiateInitialViewController() as UIViewController
vc.title = menu.name()
vc.view.backgroundColor = UIColor(netHex: colorPalette[cnt%colorPalette.count])
self.contentScrollView.addSubview(vc.view)
self.vcs.append(vc)
cnt++
}
}
```### License
MIT