Ios 我想复制这个导航栏,这是一个android版本,我该怎么做?

Ios 我想复制这个导航栏,这是一个android版本,我该怎么做?,ios,swift,uinavigationitem,Ios,Swift,Uinavigationitem,这张图片是一个android导航栏,我想用swift 3在ios中复制它。我已经在这方面工作了几天,但我不能得到正确的任何帮助将是伟大的 let height: CGFloat = 128 //whatever height you want let bounds = self.navigationController!.navigationBar.bounds self.navigationController?.navigationBar.frame = CGRect(x: 0, y: 0

这张图片是一个android导航栏,我想用swift 3在ios中复制它。我已经在这方面工作了几天,但我不能得到正确的任何帮助将是伟大的

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)

我这样做是为了获得正确的导航栏高度,但我似乎无法获得正确的导航栏按钮位置。

像这样添加按钮-

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

像这样加上按钮-

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

我不确定我是否理解您的问题,但为什么要更改导航栏的框架?如果需要左两个按钮和右一个按钮,可以使用navigationItem.LeftBarButtonims.Ems的可能副本我不确定是否理解您的问题,但为什么要更改导航栏的框架?如果需要左两个按钮和右一个按钮,可以使用navigationItem.LeftBarButtonims