UIPagerViewController wrapper
- iOS 9.0+
- Xcode 9.2
You can use CocoaPods to install PagerTab
by adding it to your Podfile
:
platform :ios, '9.0'
use_frameworks!
target 'YourTarget' do
pod "PagerTab"
end
To get the full benefits import PagerTab
import PagerTab
set up your PagerTabAppearance
let appearence = PagerTabAppearance( type: PagerTabType.fixedNumber(2),
titleColors: [(.blue, .selected), (.blue, .highlighted), (.lightGray, .normal)] )
for the different customization options take a look at PagerTabAppearance
init
public init(type: PagerTabType,
selected: Int = 0,
height: CGFloat = 50.0,
color: UIColor? = .clear,
titleColors: [(UIColor, UIControlState)]? = [(.black, .normal)],
font: UIFont = UIFont.systemFont(ofSize: UIFont.systemFontSize) ) {
...
define your viewControllers
let PoutingVC: BeautifulViewController = { let vc = BeautifulViewController(text: "😡")
vc.view.backgroundColor = UIColor.gray
return vc
}()
let BombVC: BeautifulViewController = { let vc = BeautifulViewController(text: "💣")
vc.view.backgroundColor = UIColor.lightGray
return vc
}()
let NerdVC: BeautifulViewController = { let vc = BeautifulViewController(text: "🤓")
vc.view.backgroundColor = UIColor.white
return vc
}()
let SkullVC: BeautifulViewController = { let vc = BeautifulViewController(text: "☠️")
vc.view.backgroundColor = UIColor.green
return vc
}()
set up the PagerTabPage
array
let viewControllers: [PagerTabPage] = [( PoutingVC , "Pouting"),
( BombVC , "Bomb"),
( NerdVC , "Nerd"),
( SkullVC , "Skull") ]
init your PagerTab
let pager = PagerTab( viewControllers , appearence: appearence )
add it to your view
self.add(childController: pager, toView: self.view)