Skip to content

Instantly share code, notes, and snippets.

@alfian0
Created July 5, 2018 12:30
Show Gist options
  • Save alfian0/12681e120f940a08f75b6bd822dccec0 to your computer and use it in GitHub Desktop.
Save alfian0/12681e120f940a08f75b6bd822dccec0 to your computer and use it in GitHub Desktop.
extension UIApplication {
var statusBarView: UIView? {
return value(forKey: "statusBar") as? UIView
}
}
func scrollViewDidScroll(_ scrollView: UIScrollView) {
guard let height = navigationController?.navigationBar.frame.height else { return }
var offset = scrollView.contentOffset.y / height
if offset > 1 {
offset = 1
let color = Color.pinky_red.withAlphaComponent(offset)
navigationController?.navigationBar.backgroundColor = color
UIApplication.shared.statusBarView?.backgroundColor = color
} else {
let color = Color.pinky_red.withAlphaComponent(offset)
navigationController?.navigationBar.backgroundColor = color
UIApplication.shared.statusBarView?.backgroundColor = color
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment