.holeBall1 | .holeBall2 | .holeBall3 |
---|---|---|
![]() |
![]() |
![]() |
- Swift 5+
- iOS 11.0+
- Swift tools version 5.0+ (For Swift Package Manager)
SETabView is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'SETabView'
In case the latest version (0.3.0) is not the one being installed, update the pod.
pod update 'SETabView'
The Swift Package Manager is a tool for automating the distribution of Swift code and is integrated into the swift
compiler.
Once you have your Swift package set up, adding SETabView as a dependency is as easy as adding it to the dependencies
value of your Package.swift
.
dependencies: [
.package(url: "https://github.com/eshwavin/SETabView.git", .upToNextMajor(from: "0.3.0"))
]
Download and add the files in the Source folder directly into your Xcode Project. In this case you should skip
import SETabView
in the usage instructions.
Import VCTabView
into the parent ViewController and any child View Controllers
import SETabView
Inherit the SEViewController
class in the parent ViewController
class ViewController: SEViewController {
override func viewDidLoad() {
super.viewDidLoad()
}
}
In viewDidLoad
of the parent ViewController, set the child ViewControllers.
class ViewController: SEViewController {
override func viewDidLoad() {
super.viewDidLoad()
// set the child View Controllers
setViewControllers()
}
private func setViewControllers() {
// instantiate the child View Controllers
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let firstVC = storyboard.instantiateViewController(withIdentifier: "firstVC")
let secondVC = storyboard.instantiateViewController(withIdentifier: "secondVC")
let thirdVC = storyboard.instantiateViewController(withIdentifier: "thirdVC")
let fourthVC = storyboard.instantiateViewController(withIdentifier: "fourthVC")
// assign the child View Controllers
self.viewControllers = [firstVC, secondVC, thirdVC, fourthVC]
}
}
The child ViewControllers need to conform to the SETabItem
protocol
class FirstViewController: UIViewController, SETabItem {
var tabImage: UIImage? {
return UIImage(named: "first")
}
override func viewDidLoad() {
super.viewDidLoad()
}
}
The selected tab can be changed programmatically
self.selectedTabIndex = 3
Customise the appearance and animation type of the TabBar by overriding the setTabSettings()
and setAnimationType()
functions in the parent ViewController
override func setTabSettings() {
// customise tab bar appearance
SETabView.settings.tabColor = UIColor.black
SETabView.settings.ballColor = UIColor.black
SETabView.settings.selectedTabTintColor = UIColor.white
SETabView.settings.unselectedTabTintColor = UIColor.gray
// customise animation duration
SETabView.settings.animationDuration = 1.5 // optimal duration = 1.5
}
override func setAnimationType() {
self.animationType = .holeBall3 // defaults to .holeBall3
}
- Max 5 Tabs
- Tab Bar look cannot be changed once set in
setTabSettings()
To run the example project, clone the repo, and run pod install
from the Example directory first.
Srivinayak Chaitanya Eshwa, eshwavin@gmail.com
SETabView is available under the MIT license. See the LICENSE file for more info.