我想要复制这个导航栏,这个是Android版我该怎么办?

时间:2017-08-14 11:45:49

标签: ios swift uinavigationitem

Navigation bar in android which is to be replicated in iOS

图片是一个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)

我这样做是为了让导航栏的高度正确,但我似乎无法正确显示条形按钮的位置。

1 个答案:

答案 0 :(得分:0)

像这样添加barbutton -

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