Advertisement
Guest User

Untitled

a guest
Aug 18th, 2019
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.54 KB | None | 0 0
  1. func setupNavigationBar(showBack:Bool, showMenu:Bool,isLogin:Bool)
  2. {
  3. self.navigationController?.navigationBar.isTranslucent = true
  4.  
  5. var leftItemTitle = UIBarButtonItem()
  6. var backgroundItem = UIBarButtonItem()
  7.  
  8.  
  9. let sizeLength = UIScreen.main.bounds.size.height * 2
  10. let defaultNavigationBarFrame = CGRect(x: 0, y: 0, width: sizeLength, height: 70)
  11.  
  12. let mediumView = UIView()
  13. let frame = self.navigationController?.navigationBar.frame.size
  14. mediumView.frame = CGRect(x: 0, y: 0, width: frame!.width, height: frame!.height)
  15. mediumView.backgroundColor = UIColor.red
  16.  
  17. let titleLabel = UILabel()
  18. titleLabel.text = self.menuText
  19. titleLabel.font = UIFont.systemFont(ofSize: 20)
  20. titleLabel.textColor = UIColor.white
  21. titleLabel.sizeToFit()
  22.  
  23.  
  24.  
  25. leftItemTitle = UIBarButtonItem(customView: titleLabel)
  26.  
  27.  
  28. if(!showBack && !showMenu && !isLogin){
  29. self.navigationController?.navigationBar.tintColor = UIColor.clear
  30. self.navigationItem.leftBarButtonItems?.removeAll()
  31. self.navigationItem.setHidesBackButton(true, animated:false);
  32. self.navigationController?.navigationBar.barTintColor = Utils.Color.LigthViewBackGround
  33. }
  34. else if(showBack){
  35. let backMenuButtonItem = UIBarButtonItem(image: UIImage.init(named: "backButton"), style: UIBarButtonItemStyle.done, target: self, action: #selector(backPressed))
  36. backMenuButtonItem.tintColor = UIColor.white
  37. backMenuButtonItem.width = CGFloat(30)
  38.  
  39. self.navigationItem.leftBarButtonItems = [backMenuButtonItem,leftItemTitle,]
  40. self.navigationController?.navigationBar.barTintColor = Utils.Color.backgroundBlue
  41.  
  42. }
  43. else if(showMenu){
  44. let sideMenuButtonItem = UIBarButtonItem(image: UIImage.init(named: "sideMenu"), style: UIBarButtonItemStyle.done, target: self, action: #selector(sideMenuPressed))
  45. sideMenuButtonItem.tintColor = UIColor.white
  46. sideMenuButtonItem.width = CGFloat(30)
  47.  
  48. let vistaAzul = UIView(frame: CGRect (x: 0, y: 0, width: UIScreen.main.bounds.size.width, height: 30 ))
  49. vistaAzul.backgroundColor = Utils.Color.BlueLabelText
  50.  
  51. }
  52. else if (isLogin){
  53. self.navigationController?.navigationBar.barTintColor = Utils.Color.backgroundLogin
  54. }
  55.  
  56.  
  57.  
  58.  
  59. if let hidden = navigationController?.navigationBar.isHidden
  60. {
  61. if(hidden)
  62. {
  63. self.navigationController?.navigationBar.barStyle = .default
  64. }
  65. else
  66. {
  67. self.navigationController?.navigationBar.barStyle = .black
  68. }
  69. }
  70.  
  71.  
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement