A container view controller that displays children view controllers in tabs like the profile screen on Twitter or Instagram without any dependencies. When the user scrolls the scroll view of the child view controller, the tab/segment control stick at the top.
- Custom header view
- Custom tab view
Add the HeaderStickyTabViewController.swift
file from Sources/HeaderStickyTabViewController
directory to your project.
Add this package in Xcode: https://github.com/nicnocquee/header-sticky-tab
Coming soon.
- Create a view controller that extends
HeaderStickyTabViewController
- Assign a view to
headerView
property. - Assign the children view controllers to
viewControllers
property. - Override
childDidScroll
function if needed. - Override
didChangePage
method if needed.
import HeaderStickyTabViewController
class ProfileViewController: HeaderStickyTabViewController {
static func create() -> ProfileViewController {
let vc = ProfileViewController()
vc.title = "Child"
vc.headerView = ProfileHeaderView()
vc.viewControllers = [
FirstTabViewController(style: .plain),
SecondTabViewController(style: .plain)
]
return vc
}
}
Checkout Example/HeaderStickyTab/ProfileViewController.swift
in this repository for example.
Open Example/HeaderStickyTab.xcworkspace
. Run the sample app in simulator. The example shows how to blur the header image when user pull down the scroll view.
MIT