SHARE
TWEET

Untitled

a guest Jul 12th, 2019 60 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. private func setupNavigationBar() {
  2.     navigationController?.navigationBar.isTranslucent = false
  3.     let gradientLayer = CAGradientLayer()
  4.     gradientLayer.frame.size = view.frame.size
  5.     gradientLayer.startPoint = CGPoint(x:0.0, y:0.0)
  6.     gradientLayer.endPoint = CGPoint(x:1.0, y:0.0)
  7.     //gradient colors to be used in gradient of menu bar
  8.     let blue = UIColor(red: 64/255.0, green: 100/255.0, blue: 142/255.0, alpha: 1.0)
  9.     let red = UIColor(red: 145/255.0, green: 82/255.0, blue: 89/255.0, alpha: 1.0)
  10.     //let middle = UIColor(red: 107/255.0, green: 94/255.0, blue: 122/255.0, alpha: 1.0)
  11.     gradientLayer.colors = [blue.cgColor, red.cgColor]
  12.     navigationController?.navigationBar.backgroundColor = gradientLayer
  13.     let imageView = UIImageView(frame: CGRect(x: 0, y: 0, width: 120, height: 40))
  14.     imageView.widthAnchor.constraint(equalToConstant: 75.0).isActive = true
  15.     let image = UIImage(named: "logo")
  16.     imageView.image = image
  17.     imageView.layer.cornerRadius = 10
  18.     navigationItem.titleView = imageView
  19.  
  20.     let navButton = UIButton(frame: CGRect(x: 0, y: 0, width: 40, height: 10))
  21.     let searchImage = UIImage(named: "side_menu")?.withRenderingMode(.alwaysOriginal)
  22.     navButton.widthAnchor.constraint(equalToConstant: 32.0).isActive = true
  23.     navButton.setBackgroundImage(searchImage, for: .normal)
  24.     navButton.addTarget(self, action:  #selector(handleMore), for: .touchUpInside)
  25.     navigationItem.leftBarButtonItem = UIBarButtonItem(customView: navButton)
  26.  
  27. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top