Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private func setupNavigationBar() {
- navigationController?.navigationBar.isTranslucent = false
- let gradientLayer = CAGradientLayer()
- gradientLayer.frame.size = view.frame.size
- gradientLayer.startPoint = CGPoint(x:0.0, y:0.0)
- gradientLayer.endPoint = CGPoint(x:1.0, y:0.0)
- //gradient colors to be used in gradient of menu bar
- let blue = UIColor(red: 64/255.0, green: 100/255.0, blue: 142/255.0, alpha: 1.0)
- let red = UIColor(red: 145/255.0, green: 82/255.0, blue: 89/255.0, alpha: 1.0)
- //let middle = UIColor(red: 107/255.0, green: 94/255.0, blue: 122/255.0, alpha: 1.0)
- gradientLayer.colors = [blue.cgColor, red.cgColor]
- navigationController?.navigationBar.backgroundColor = gradientLayer
- let imageView = UIImageView(frame: CGRect(x: 0, y: 0, width: 120, height: 40))
- imageView.widthAnchor.constraint(equalToConstant: 75.0).isActive = true
- let image = UIImage(named: "logo")
- imageView.image = image
- imageView.layer.cornerRadius = 10
- navigationItem.titleView = imageView
- let navButton = UIButton(frame: CGRect(x: 0, y: 0, width: 40, height: 10))
- let searchImage = UIImage(named: "side_menu")?.withRenderingMode(.alwaysOriginal)
- navButton.widthAnchor.constraint(equalToConstant: 32.0).isActive = true
- navButton.setBackgroundImage(searchImage, for: .normal)
- navButton.addTarget(self, action: #selector(handleMore), for: .touchUpInside)
- navigationItem.leftBarButtonItem = UIBarButtonItem(customView: navButton)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement