Latest1.0.8
Homepagehttps://github.com/horitaku46/SilentScrolly
LicenseMIT
Platformsios 11.0
Authors

SilentScrolly

Platform
Swift
Cocoapods
Carthage compatible
License

Overview

Scroll to hide navigationBar, tabBar and toolBar.

SilentScrolly

Features

Adding too much UIGestureRecognizer to the UIView makes handling difficult, so it was handled by UIScrollViewDelegate.

Requirements

  • Xcode 9.0+
  • iOS 10+
  • Swift 4.0+

Installation

CocoaPods

pod 'SilentScrolly'

Carthage

github "horitaku46/SilentScrolly"

Usage

See Example, for more details.

《1》 If you want to change the color of the statusBar, add func statusBarStyle(showStyle: UIStatusBarStyle, hideStyle: UIStatusBarStyle) to the UINavigationController.

import UIKit

final class NavigationController: UINavigationController {

    override var preferredStatusBarStyle: UIStatusBarStyle {
        return topViewController?.preferredStatusBarStyle ?? .default
    }
}

《2》 Please describe accordingly as below.

import UIKit

final class TableViewController: UIViewController, SilentScrollable {

    override var preferredStatusBarStyle: UIStatusBarStyle {
        return statusBarStyle(showStyle: .lightContent, hideStyle: .default) // Optional
    }

    @IBOutlet weak var tableView: UITableView! {
        didSet {
            tableView.register(UITableViewCell.self, forCellReuseIdentifier: "Cell")
            tableView.delegate = self
            tableView.dataSource = self
        }
    }

    var silentScrolly: SilentScrolly?

    override func viewDidLayoutSubviews() {
        super.viewDidLayoutSubviews()
        silentDidLayoutSubviews()
    }

    override func viewDidAppear(_ animated: Bool) {
        super.viewDidAppear(animated)
        configureSilentScrolly(tableView, followBottomView: tabBarController?.tabBar)
    }

    override func viewWillDisappear(_ animated: Bool) {
        super.viewWillDisappear(animated)
        silentWillDisappear()
    }

    override func viewDidDisappear(_ animated: Bool) {
        super.viewDidDisappear(animated)
        silentDidDisappear()
    }

    override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
        super.viewWillTransition(to: size, with: coordinator)
        silentWillTranstion()
    }
}

extension TableViewController: UITableViewDelegate {

    func scrollViewDidScroll(_ scrollView: UIScrollView) {
        silentDidScroll()
    }

    func scrollViewDidZoom(_ scrollView: UIScrollView) {
        silentDidZoom() // Optional
    }

    func scrollViewShouldScrollToTop(_ scrollView: UIScrollView) -> Bool {
        showNavigationBar() // Optional
        return true
    }
}

extension TableViewController: UITableViewDataSource {

    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return 100
    }

    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath)
        cell.textLabel?.text = "Row: (indexPath.row)"
        return cell
    }
}

Author

Takuma Horiuchi

License

SilentScrolly is available under the MIT license. See the LICENSE file for more info.

Latest podspec

{
    "name": "SilentScrolly",
    "version": "1.0.8",
    "summary": "Scroll to hide navigationBar, tabBar and toolBar.",
    "description": "Adding too much UIGestureRecognizer to the UIView makes handling difficult, so it was handled by UIScrollViewDelegate.",
    "homepage": "https://github.com/horitaku46/SilentScrolly",
    "license": {
        "type": "MIT",
        "file": "./LICENSE"
    },
    "authors": {
        "Takuma Horiuchi": "[email protected]"
    },
    "social_media_url": "https://twitter.com/horitaku46",
    "platforms": {
        "ios": "11.0"
    },
    "source": {
        "git": "https://github.com/horitaku46/SilentScrolly.git",
        "tag": "1.0.8"
    },
    "source_files": "SilentScrolly/**/*.{swift}",
    "swift_version": "4.0"
}

Pin It on Pinterest

Share This