2017-08-14 47 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 
相關問題