0
我通過故事板添加了自定義導航欄。我期待屏幕上的內容自動向下移動。但它完全覆蓋了屏幕頂部的內容..是否有一行簡潔的代碼會自動在導航欄和視圖本身之間創建間距?添加覆蓋屏幕內容的自定義導航欄
我通過故事板添加了自定義導航欄。我期待屏幕上的內容自動向下移動。但它完全覆蓋了屏幕頂部的內容..是否有一行簡潔的代碼會自動在導航欄和視圖本身之間創建間距?添加覆蓋屏幕內容的自定義導航欄
您可能已經聽說過Cocpods,我覺得這是一個更好的方式去找fragom導航欄。 你只需要實現的協議,給你需要的導航欄中 經過以下閉門
規格只需撥打從viewDidLoad中此方法:
func createNavBar() {
let leftNavigationButton = UIButton()
leftNavigationButton.setImage(UIImage(named: "ic_back.png"), forState: .Normal)
leftNavigationButton.frame = CGRectMake(10, 10, 20, 15)
leftNavigationButton.addTarget(self, action: "onBackButtonPressed:", forControlEvents: UIControlEvents.TouchUpInside)
let customBarItem = UIBarButtonItem(customView: leftNavigationButton)
self.navigationItem.leftBarButtonItem = customBarItem;
//set TitleAppIcon
let GR = UITapGestureRecognizer(target: self, action: Selector("headerLogoTapAction:"))
let imageView = UIImageView(frame: CGRect(x: 90, y: 0, width: ((UIScreen.mainScreen().bounds.width)/3), height: 40))
imageView.contentMode = .ScaleAspectFit
let image = UIImage(named: "yourimag.png") //or set title
imageView.image = image
imageView.addGestureRecognizer(GR)
imageView.userInteractionEnabled = true
navigationItem.titleView = imageView
}
希望這會幫助你
顯示你的代碼,你如何添加自定義導航欄 – PiyushRathi
簡單的出路設置頂部約束爲84 64導航欄和20狀態B AR –