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)
我这样做是为了让导航栏的高度正确,但我似乎无法得到酒吧按钮的位置正确。
最佳答案
像这样添加按钮-
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
关于ios - 我想复制此导航栏,这是一个android版本,我该怎么做?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/45673809/