2017-08-14 46 views
1

Navigation bar in android which is to be replicated in iOS我想复制这个导航栏,这是一个android版本,我该怎么做呢?

的图片是我想在IOS复制使用SWIFT 3.一个机器人的导航栏,我一直在做这个了几天,现在的,但我不能得到正确的帮助将是巨大的。

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) 

我已经做到了这一点得到的导航栏右侧的高度,但我不能似乎得到的栏按钮右侧的位置。

+0

我不知道,我明白你的问题,但为什么要更改导航栏的框架?如果您需要左右两个按钮,则可以使用navigationItem.leftBarButtonItems。 – Woof

+0

[更改导航栏iOS Swift的高度]的可能重复(https://stackoverflow.com/questions/32142375/changing-the-height-of-the-navigation-bar-ios-swift) – zombie

回答

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 
相关问题