https://github.com/appscomtr/apfancypager
A fancy pager view controller framework for Swift/Objective-C
https://github.com/appscomtr/apfancypager
carthage cocoapods pager swift viewpager
Last synced: about 1 year ago
JSON representation
A fancy pager view controller framework for Swift/Objective-C
- Host: GitHub
- URL: https://github.com/appscomtr/apfancypager
- Owner: AppsComTr
- License: mit
- Created: 2018-10-10T12:13:50.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-05-03T11:30:22.000Z (about 7 years ago)
- Last Synced: 2025-04-14T01:37:34.464Z (about 1 year ago)
- Topics: carthage, cocoapods, pager, swift, viewpager
- Language: Swift
- Homepage: https://appscomtr.github.io/APFancyPager/
- Size: 15.4 MB
- Stars: 6
- Watchers: 5
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# APFancyPager
A fancy pager view controller framework for Swift/Objective-C
[](https://app.codacy.com/app/mertsimsek/APFancyPager?utm_source=github.com&utm_medium=referral&utm_content=AppsComTr/APFancyPager&utm_campaign=Badge_Grade_Dashboard)
[](https://travis-ci.org/AppsComTr/APFancyPager)
[](https://github.com/AppsComTr/APFancyPager)
[](https://cocoapods.org/pods/APFancyPager)
[](https://github.com/Carthage/Carthage)
[](https://raw.githubusercontent.com/AppsComTr/APFancyPager/master/LICENSE)
## Installation
### Cocoapods
Simply add the APFancyPager to your Podfile:
`pod 'APFancyPager'`
### Carthage
You can use Carthage as well. Paste below line to your Cartfile:
`github "AppsComTr/APFancyPager"`
### Manual
Also, you can copy-paste the Swift files directly into your project.
## Usage
You can check the demo project to get the basics of the framework.
Simply make your view controller extend APFancyPagerViewController and also implement the data source and optionally the delegate.
You should use the below data source function in order to specify the number of pages that APFancyPager will show.
```swift
func numberOfViewControllers(in fancyPagerViewController: APFancyPagerViewController) -> Int {
return pages.count
}
```
Also you should return your desired header height from the data source function below.
```swift
func heightForHeader(_ fancyPagerViewController: APFancyPagerViewController) -> CGFloat {
return 100.0
}
```
You should return related view controller into pages by using
```swift
func fancyPagerViewController(_ fancyPagerViewController: APFancyPagerViewController, viewControllerForIndex index: Int) -> UIViewController
```
Just return your view controller for related index.
You want to show header titles for your fancy pager, don't you? Here, use below data source function o achieve this:
```swift
func fancyPagerViewController(_ fancyPagerViewController: APFancyPagerViewController, headerStringForIndex index: Int) -> String
```
For the text color of the header at index this:
```swift
func fancyPagerViewController(_ fancyPagerViewController: APFancyPagerViewController, headerTextColorForIndex index: Int) -> UIColor
```
and for the background color at index, this:
```swift
func fancyPagerViewController(_ fancyPagerViewController: APFancyPagerViewController, headerBackgroundColorForIndex index: Int) -> UIColor
```
There are 2 delegate functions which are
```swift
func fancyPagerViewController(_ fancyPagerViewController: APFancyPagerViewController, didScrollToIndex index: Int)
```
and
```swift
func fancyPagerViewController(_ fancyPagerViewController: APFancyPagerViewController, isScrollingFromIndex fromIndex: Int, toIndex: Int, progress: CGFloat)
```
You can use them to get some useful (maybe not useful that much) informations about the APFancyPager.
The last but not least, you can use an extra function to scroll the APFancyPager to the any index directly. To achieve this, simply use below function:
```swift
func scrollToPage(_ pageNumber: Int, animated: Bool)
```
## Preview

## License
APFancyPager is released under the MIT license. See [LICENSE](https://github.com/AppsComTr/APFancyPager/blob/master/LICENSE) for details.