如何以编程方式更改UINavigationBar高度?
如何使用代码int iOS8 swift更改UINavigationBar高度?
我试过使用:
UINavigationBar.resizableSnapshotViewFromRect UINavigationBar.drawViewHierarchyInRect UINavigationBar.frameForAlignmentRect
这些似乎都没有做到这一点。
这里是你的例子:
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) } }