Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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