Question: I am trying to add a ***custom view*** on right of **UINavigationBar**. What I tried is the following, but the view is not showing up! Please help, thanks in advance! 

```
let viewOnrightButton = UIView(frame: CGRect(x: 2, y: 2, width: 60, height: 22))
 // viewOnrightButton.frame = CGRectMake(2, 2, 60, 22)
viewOnrightButton.layer.cornerRadius = 2
viewOnrightButton.backgroundColor = UIColor(red: 0.961, green: 0.827, blue: 0.239, alpha: 1.00)

lblNumbersOfBanana.frame = CGRectMake(2, 1, viewOnrightButton.frame.width-20, 20)
lblNumbersOfBanana.text = "001"

var bananaImgView = UIImageView(frame: CGRect(x: viewOnrightButton.frame.width-22, y: 0, width: 20, height: 20))
 //  bananaImgView.frame = CGRectMake(viewOnrightButton.frame.width-22, 0, 20, 20)
bananaImgView.image = UIImage(named: "banana")

viewOnrightButton.addSubview(lblNumbersOfBanana)
viewOnrightButton.addSubview(bananaImgView)

self.navigationItem.rightBarButtonItem?.customView = viewOnrightButton

```

Answer: 
You can do like this, try it:

```
var view = UIView(frame: CGRectMake(0, 0, 100, 44))
view.backgroundColor = UIColor.yellowColor()
var barButtonItem = UIBarButtonItem(customView: view)
self.navigationItem.rightBarButtonItem = barButtonItem

```
I add this code in viewWillAppear(), and work for me

```
override func viewWillAppear(_ animated: Bool) {
    super.viewWillAppear(animated)
    self.navigationController?.navigationBar.isHidden = false
    self.navigationItem.title = "Forgot Password?"
    self.navigationItem.leftBarButtonItem = UIBarButtonItem(customView:UIImageView(image: UIImage(named: "btn_back")))
}

```