https://github.com/horitaku46/silentscrolly
Scroll to hide navigationBar, tabBar and toolBar.
https://github.com/horitaku46/silentscrolly
carthage cocoapods hide swift swift4 uinavigationbar uiscrollview uitabbar uitoolbar
Last synced: about 1 year ago
JSON representation
Scroll to hide navigationBar, tabBar and toolBar.
- Host: GitHub
- URL: https://github.com/horitaku46/silentscrolly
- Owner: horitaku46
- License: mit
- Created: 2018-02-20T03:27:13.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-05-14T04:09:03.000Z (about 8 years ago)
- Last Synced: 2024-10-31T16:24:20.117Z (over 1 year ago)
- Topics: carthage, cocoapods, hide, swift, swift4, uinavigationbar, uiscrollview, uitabbar, uitoolbar
- Language: Swift
- Homepage:
- Size: 62.5 KB
- Stars: 85
- Watchers: 8
- Forks: 9
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://developer.apple.com/iphone/index.action)

[](https://img.shields.io/badge/Cocoapods-compatible-brightgreen.svg)
[](https://github.com/Carthage/Carthage)
[](http://mit-license.org)
## Overview
Scroll to hide navigationBar, tabBar and toolBar.
## Features
Adding too much `UIGestureRecognizer` to the `UIView` makes handling difficult, so it was handled by `UIScrollViewDelegate`.
## Translation
Mr. [Gargo](https://github.com/Gargo) translated [this README into Russian](http://gargo.of.by/silentscrolly/)!🙇♂️
## Requirements
- Xcode 9.0+
- iOS 10+
- Swift 4.0+
## Installation
### CocoaPods
```ruby
pod 'SilentScrolly'
```
### Carthage
```ruby
github "horitaku46/SilentScrolly"
```
## Usage
**See [Example](https://github.com/horitaku46/SilentScrolly/tree/master/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`.
```swift
import UIKit
final class NavigationController: UINavigationController {
override var preferredStatusBarStyle: UIStatusBarStyle {
return topViewController?.preferredStatusBarStyle ?? .default
}
}
```
**《2》** Please describe accordingly as below.
```swift
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
- [Facebook](https://www.facebook.com/profile.php?id=100008388074028)
- [Twitter](https://twitter.com/horitaku_)
- [GitHub](https://github.com/horitaku46)
## License
`SilentScrolly` is available under the MIT license. See the [LICENSE](./LICENSE) file for more info.