1

Navigation bar in android which is to be replicated in iOS

The picture is of a android navigation bar which i want to replicate in ios using swift 3. I have been working on this for few days now but i cant get it right any help will be great.

let height: CGFloat = 128  //whatever height you want
let bounds = self.navigationController!.navigationBar.bounds
self.navigationController?.navigationBar.frame = CGRect(x: 0, y: 0, width: bounds.width, height: bounds.height + height)

i have done this to get the height of navigation bar right but i cant seem to get the position of bar button right.

Shamas S
  • 7,507
  • 10
  • 46
  • 58
Nikesh Hyanju
  • 140
  • 3
  • 16
  • I'm not sure that I understand your question, but why are going to change the frame of the navbar? If you need to have two button left and one right, you can use navigationItem.leftBarButtonItems. – Woof Aug 14 '17 at 11:55
  • Possible duplicate of [Changing the height of the Navigation bar iOS Swift](https://stackoverflow.com/questions/32142375/changing-the-height-of-the-navigation-bar-ios-swift) – zombie Aug 14 '17 at 12:04

1 Answers1

0

Add barbutton like this-

let myBackButton = UIButton(type: .custom)
myBackButton.addTarget(self, action: #selector(backAction), for: UIControlEvents.touchUpInside)
myBackButton.setTitle("YOUR TITLE", for: UIControlState.normal)
myBackButton.setTitleColor(UIColor.blue, for: UIControlState.normal)
myBackButton.sizeToFit()
myBackButton.frame = CGRect(x: 0, y: 0, width: 30, height: 30)
let myCustomBackButtonItem:UIBarButtonItem = UIBarButtonItem(customView: myBackButton)
self.navigationItem.leftBarButtonItem  = myCustomBackButtonItem
Abhishek Jain
  • 4,557
  • 2
  • 32
  • 31