Latest 0.0.5
License MIT
Platforms ios 9.0, requires ARC
Dependencies SnapKit

License MIT
Pod version
Platform info
Swift 4.2

A pure-Swift library for nested display of horizontal and vertical scrolling views.



  • iOS 9.0+
  • Swift 4.2+
  • Xcode 10+


CocoaPods (recommended)


pod 'Shazam'



First make sure to import the framework:

import Shazam

Basically, we just need to provide the list of child view controllers to show. Then call some necessary methods.

Let’s see the steps to do this:

Create a ShazamPageViewController subclass

import Shazam

class PageViewController: ShazamPageViewController {
  // ...

Provide the view controllers that will appear embedded into the ShazamPageViewController

override func numberOfViewControllers(in pageController: ShazamPageViewController) -> Int {
    return count

override func pageController(_ pageController: ShazamPageViewController, viewControllerAt index: Int) -> (UIViewController & ShazamChildViewController) {
    // ...
    return viewController

Every UIViewController that will appear within the ShazamPageViewController should conform to ShazamChildViewController by implementing func shazamChildScrollView() -> UIScrollView

import Shazam
class ChildViewController: UIViewController, ShazamChildViewController {

    @IBOutlet weak var tableView: UITableView!
    func shazamChildScrollView() -> UIScrollView {
        return tableView
    // ...

Note: The scrollview of ChildViewController must reserve the height of headerView + menuView at the top. For example, in BatmanViewController in Demo, you need to set the height of Header of collectionView.

func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForHeaderInSection section: Int) -> CGSize {
        guard let pageViewContoller = szPageViewContoller else {
            return .zero
        let headerViewHeight = pageViewContoller.headerViewHeightFor(pageViewContoller)
        let menuViewHeight = pageViewContoller.menuViewHeightFor(pageViewContoller)
        return CGSize(width: collectionView.bounds.width, height: headerViewHeight + menuViewHeight)

Provide the headerView and headerView height

override func headerViewFor(_ pageController: ShazamPageViewController) -> UIView & ShazamHeaderView {
    return HeaderView()

override func headerViewHeightFor(_ pageController: ShazamPageViewController) -> CGFloat {
    return headerViewHeight

The headerView should conform to ShazamHeaderView by implementing func userInteractionViews() -> [UIView]?

func userInteractionViews() -> [UIView]? {

Provide the menuView and menuView height

override func menuViewFor(_ pageController: ShazamPageViewController) -> UIView {
    return menuView

override func menuViewHeightFor(_ pageController: ShazamPageViewController) -> CGFloat {
    return menuViewHeight

Update menuView’s layout when main scroll view did scroll and check state when did end scoll

override func pageController(_ pageController: ShazamPageViewController, mainScrollViewDidScroll scrollView: UIScrollView) {

override func pageController(_ pageController: ShazamPageViewController,
                                 mainScrollViewDidEndScroll scrollView: UIScrollView) {


Follow these 4 steps to run Example project:

  1. Clone Shazam repository
  2. Run the pod install command
  3. Open Shazam workspace
  4. Run the Shazam-Demo project.


Shazam is released under the MIT license. See LICENSE for details.

Latest podspec

    "name": "Shazam",
    "version": "0.0.5",
    "summary": "An easy solution to nested scrolling",
    "homepage": "",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    "authors": {
        "bawn": "[email protected]"
    "swift_versions": "4.2",
    "source": {
        "git": "",
        "tag": "0.0.5"
    "platforms": {
        "ios": "9.0"
    "requires_arc": true,
    "dependencies": {
        "SnapKit": []
    "source_files": [
    "swift_version": "4.2"

Pin It on Pinterest

Share This