/ViewControllersPager

The easiest way to create paging view controllers in swift, and support RTL Languages

Primary LanguageSwiftMIT LicenseMIT

Language

The easiest way to create paging view controllers in swift.

Installation

Drop in the Spring folder to your Xcode project.

Or via CocoaPods pre-release:

platform :ios, '8.0'
pod 'ViewControllersPager'
use_frameworks!

Usage

Subclass PagerController (as it's a UIViewController subclass) and implement data source methods in the subclass. Note: don't forgot to add PagerController, PagerDataSource and PagerDelegate in your ViewController to access its delegate and dataSource functions.

Usage with Code

override func viewDidLoad() {
	super.viewDidLoad()
	self.dataSource = self
        self.delegate = self
}

Data Source

func numberOfTabs(pager: PagerController) -> Int
func tabViewForIndex(index: Int, pager: PagerController) -> UIView
optional func viewForTabAtIndex(index: Int, pager: PagerController) -> UIView
optional func controllerForTabAtIndex(index: Int, pager: PagerController) -> UIViewController

Delegate

optional func didChangeTabToIndex(pager: PagerController, index: Int)
optional func didChangeTabToIndex(pager: PagerController, index: Int, previousIndex: Int)
optional func didChangeTabToIndex(pager: PagerController, index: Int, previousIndex: Int, swipe: Bool)

Customize

If you want, you chan change tabs appearance and customize it with your needs completely! In this part you can see configuration properties:

  • Confige to set ViewControllers background color, its default value is white
var contentViewBackgroundColor: UIColor = UIColor.white
  • Confige to set indicator background color, its default value is red
var indicatorColor: UIColor = UIColor.red
  • Confige to set tabs background color, its default value is gray
var tabsViewBackgroundColor: UIColor = UIColor.gray
  • Confige to set text of tabs text color, its default value is white
tabsTextColor: UIColor = UIColor.white
  • Confige to set text of selected tab text color, its default value is white
selectedTabTextColor = UIColor.white
  • If you setup pager with icons, you can set tabs icons contentMode, its default value is scaleAspectFit
tabsImageViewContentMode = UIView.ContentMode.scaleAspectFit
  • Confige to set datasource of page viewer
weak var dataSource: PagerDataSource?
  • Confige to set delegate of page viewer
weak var delegate: PagerDelegate?
  • Confige to set height of the tabs, its default value is 44.0
var tabHeight: CGFloat = 44.0
  • If you want set space above the page view controller, set this property, its default value is 0.0
var tabTopOffset: CGFloat = 0.0
  • Confige to set tabs offset, its default value is 56.0
var tabOffset: CGFloat = 56.0
  • Confige to set tabs width, its default value is 128.0
var tabWidth: CGFloat = 128.0
  • Confige to set tabs title text font, its default value is boldSystemFont(ofSize: 16.0)
var tabsTextFont: UIFont = UIFont.boldSystemFont(ofSize: 16.0)
  • Confige to set the height of indicator, its default value is 5.0
var indicatorHeight: CGFloat = 5.0
  • You could set the position of tabs, in bottom of page view controller or in top of it, the default position is top
var tabLocation: PagerTabLocation = PagerTabLocation.top
  • If you want set animation while sweept the tabs, set this property, its default value is
    PagerAnimation.during
var animation: PagerAnimation = PagerAnimation.during
  • Confige Other peoperties:
var startFromSecondTab : Bool = false
var centerCurrentTab : Bool = false
var fixFormerTabsPositions : Bool = false
var fixLaterTabsPosition : Bool = false
var ignoreTopBarHeight : Bool = false
var ignoreBottomBarHeight : Bool = false

Support RTL Languages

ViewControllersPager support RTL languages too, if you want config it for RTL languages, just set isRTL property to true, and enjoy it!

var isRTL			: Bool = false (By default it's FALSE!)

Contact

ViewControllersPager was a forked from Pager to swift.

Licence

Pager is MIT licensed. See the LICENCE file for more info.