Navigation bar in iOS 6 look like bar in iOS 7

北城余情 提交于 2020-01-01 09:18:21

问题


Is there any way to make navigation bar elements (back button) in iOS 6 look like navigation bar elements in iOS 7 ? And also buttons and other iOS 7 elements of UI.


回答1:


Instead of putting code into every view controller that you need to customize, I would recommend doing this for the entire application by putting something like this in your application:didFinishLaunchingWithOptions: method in the App Delegate

// Nav bar
[[UINavigationBar appearance] setBackgroundImage:[[UIImage imageNamed:@"navBar.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(10, 5, 10, 5)] forBarMetrics:UIBarMetricsDefault];

// Back buttons
[[UIBarButtonItem appearance] setBackButtonBackgroundImage:[UIImage imageNamed:@"backNavButton.png"] forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];

// Toolbar
[[UIToolbar appearance] setBackgroundImage:[[UIImage imageNamed:@"toolbar.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(10, 5, 10, 5)] forToolbarPosition:UIToolbarPositionAny barMetrics:UIBarMetricsDefault];



回答2:


You can customize the navigation bar by setting the background Image like this

[self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"topbar.png"] forBarMetrics:UIBarMetricsDefault];

And you can add a customize bar with setLeftBarButtonItems method like this.

[self.navigationItem setLeftBarButtonItems:];


来源:https://stackoverflow.com/questions/19179528/navigation-bar-in-ios-6-look-like-bar-in-ios-7

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!