如何使用代码int iOS8 swift更改UINavigationBar高度?
我尝试过使用:
UINavigationBar.resizableSnapshotViewFromRect
UINavigationBar.drawViewHierarchyInRect
UINavigationBar.frameForAlignmentRect
这些似乎都没有实现这一目标。
答案 0 :(得分:3)
以下是您的示例:
import UIKit
class BaseViewConroller: UIViewController {
var navBar:UINavigationBar=UINavigationBar()
override func viewDidLoad() {
super.viewDidLoad()
setNavBarToTheView()
// Do any additional setup after loading the view.
self.title="test test"
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
func setNavBarToTheView()
{
navBar.frame=CGRectMake(0, 0, 320, 50) // Here you can set you Width and Height for your navBar
navBar.backgroundColor=(UIColor .blackColor())
self.view .addSubview(navBar)
}
}