How to add custom view on right of navigation bar Swift?

前端 未结 6 1559
猫巷女王i
猫巷女王i 2020-12-16 21:59

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! Pleas

6条回答
  •  旧巷少年郎
    2020-12-16 22:19

    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
    

提交回复
热议问题