Tabman is a powerful paging view controller with indicator bar, for iOS.

Features

  • Super easy to implement page view controller with indicator bar.
  • Multiple indicator bar styles.
  • Simplistic, yet highly extensive customisation.
  • Full support for custom components.
  • Built on a powerful and informative page view controller, Pageboy.

Requirements

Tabman requires iOS 8 or above, Swift 4 and uses Pageboy 2.

For details on using older versions of Tabman or Swift please see Compatibility.

Installation

CocoaPods

Tabman is available through CocoaPods. To install it, simply add the following line to your Podfile:

Pod 'Tabman', '~ > 1.0'Copy the code

And run pod install.

Carthage

Tabman is also available through Carthage. Simply install carthage with Homebrew using the following command:

$ brew update
$ brew install carthageCopy the code

Add Tabman to your Cartfile:

Making "uias/Tabman" ~ > 1.0Copy the code

Dependencies

  • Pageboy by Merrick Sapsford
  • PureLayout by PureLayout

Example

An example project is available to take a look at some of the features that Tabman offers. To run the example, simply clone the repo, run

carthage bootstrap --platform ios
Copy the code

and build the workspace.

Usage

The Basics

  1. Create an instance of TabmanViewController and provide it with a PageboyViewControllerDataSource, also configuring the items you want to display in the TabmanBar. Note: TabmanViewController conforms to and is set as the PageboyViewControllerDelegate.
class YourTabViewController: TabmanViewController, PageboyViewControllerDataSource {

	override func viewDidLoad() {
		super.viewDidLoad()

		self.dataSource = self

        	// configure the bar
        	self.bar.items = [Item(title: "Page 1"),
                          	  Item(title: "Page 2")]
	}
}Copy the code
  1. Implement PageboyViewControllerDataSource.
func numberOfViewControllers(in pageboyViewController: PageboyViewController) -> Int {
    return viewControllers.count
}
    
func viewController(for pageboyViewController: PageboyViewController,
                    at index: PageboyViewController.PageIndex) -> UIViewController? {
    return viewControllers[index]
}
    
func defaultPage(for pageboyViewController: PageboyViewController) -> PageboyViewController.Page? {
    return nil
}Copy the code
  1. All done!

Page View Controller

As Tabman is based on Pageboy, all the extras and niceities in a PageboyViewController are available in aTabmanViewController. Including:

  • Simplified data source management.
  • Enhanced delegation; featuring exact relative positional data and reliable updates.
  • Infinite scrolling support.
  • Automatic timer-based page transitioning.
  • Support for custom page transitions.

Read up on the Pageboy documentation here.

Child Content Insetting

Tabman will automatically attempt to inset any UIScrollView that if finds within it’s child view controllers. This is enabled by default:

.automaticallyAdjustsChildScrollViewInsets = trueCopy the code

The values used for insetting the child content are also available for manual use at bar.requiredInsets. Additionally, additionalSafeAreaInsets are also configured to allow for content to be pinned to the safe areas when running iOS 11.

Automatic insetting support is available for any UIScrollView derived class such as UITableView and also view controllers such as UITableViewController and UICollectionViewController.

Troubleshooting – If you are having issues with the automatic insetting behaviour of Tabman, please check out the Automatic Insetting Troubleshooting Guide. If you still are having issues, please raise an issue.

Customization

The TabmanBar in Tabman can be completely customized to your liking, by simply modifying the available properties in the .bar TabmanBar.Config object.

Style

The style of bar to display, by default this is set to .scrollingButtonBar.

tabViewController.bar.style = .buttonBarCopy the code
Available Styles:

For examples on implementing real-world bar styles with Tabman, check out Tabman-Styles.

Location

Choose where you want the bar to appear, by default this is set to .preferred which will use the predefined preferred location for the active style.

tabViewController.bar.location = .topCopy the code

Note: The bar will automatically take UIKit components such as UINavigationBar and UITabBar into account.

Appearance

Customization of the appearance and styling of a bar is available via .appearance. Providing a TabmanBar.Appearance object with your desired configuration will instantly update the appearance of the active bar:

tabViewController.bar.appearance = TabmanBar.Appearance({ (appearance) in

	// customise appearance here
	appearance.text.color = UIColor.red
	appearance.indicator.isProgressive = true
})Copy the code

The full list of appearance properties can be found here.

For more advanced customisation, including defining your own indicator and bar styles please read here.

Behaviors

You can also enable different behaviors via .behaviors. Simply provide an array of your desired TabmanBar.Behavior values and the bar will start using them:

tabViewController.bar.behaviors = [.autoHide(.always)]Copy the code

The full list of available behaviors can be found here.

Troubleshooting

If you are encountering issues with Tabman, please check out the Troubleshooting Guide.

If you’re still having problems, feel free to raise an issue.

About

Contributing

Bug reports and pull requests are welcome on GitHub at github.com/uias/Tabman.

License

The library is available as open source under the terms of the MIT License.