Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arifinfrds/fc123b3d52de3b59c70605bd456f2762 to your computer and use it in GitHub Desktop.
Save arifinfrds/fc123b3d52de3b59c70605bd456f2762 to your computer and use it in GitHub Desktop.
Simple Example of Clean Method Implementation.
import UIKit
extension ViewController: UITableViewDelegate {
// Some UITableViewDelegate method
// ...
func scrollViewDidScroll(_ scrollView: UIScrollView) {
let verticalOffset = tableView.contentOffset.y
verticalOffset >= 64
? setupNavbarAppereanceNotTransparentWhenScolling()
: setupNavBarAppereanceTransparentWhenScrolling()
}
}
extension ViewController {
private func setupNavbarAppereanceNotTransparentWhenScolling() {
navigationController?.unTransparentNavBar(tintColor: Resources.Color.primaryColor, barTintColor: .white)
let textAttributes = [NSAttributedStringKey.foregroundColor: UIColor.black]
navigationController?.navigationBar.titleTextAttributes = textAttributes
}
private func setupNavBarAppereanceTransparentWhenScrolling() {
navigationController?.transparentNavBar(tintColor: .white)
let textAttributes = [NSAttributedStringKey.foregroundColor: UIColor.clear]
navigationController?.navigationBar.titleTextAttributes = textAttributes
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment