I want to apply gradient color on navigation bar. I applied that but the status bar color is not changing. Can anyone help me with this?
Here is the code for implementing the gradient color:
let colorTop = UIColor(red: 69/255, green: 90/255, blue: 195/255, alpha: 1.0).CGColor
let colorBottom = UIColor(red: 230/255, green: 44/255, blue: 75/255, alpha: 1.0).CGColor
let gradientLayer = CAGradientLayer()
gradientLayer.colors = [ colorTop, colorBottom]
gradientLayer.locations = [ 0.0, 1.0]
gradientLayer.frame = CGRectMake(0, 0, 375, 64)
self.navigationController?.navigationBar.layer.addSublayer(gradientLayer)
Use this:
gradientLayer.frame = CGRect(x:0, y:-20, width:375, height:64)
let colorTop = UIColor(red: 69/255, green: 90/255, blue: 195/255, alpha: 1.0).cgColor
let colorBottom = UIColor(red: 230/255, green: 44/255, blue: 75/255, alpha: 1.0).cgColor
let gradientLayer = CAGradientLayer()
gradientLayer.colors = [ colorTop, colorBottom]
gradientLayer.locations = [ 0.0, 1.0]
gradientLayer.frame = CGRect(x:0, y:-20, width:375, height:64)
self.navigationController?.navigationBar.layer.addSublayer(gradientLayer)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With