Simple Example of Clean Method Implementation.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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