在MorenavigationController导航栏IOS 5中更改图像背景
-
14-11-2019 - |
题
这是appdelegate:
UINavigationController *moreController = _tbc.moreNavigationController;
moreController.navigationBar.tintColor = [UIColor blackColor];
UIImage *image = [UIImage imageNamed:@"navBar.png"];
[image drawInRect:rect];
/* UITableView *moreTableView = (UITableView *)moreController.topViewController.view;
// [moreTableView initWithFrame:CGRectZero style:UITableViewStyleGrouped];
[moreTableView setBackgroundColor:BACKGROUNDCOLOUR];*/
.
只有当我更改背景颜色时才有效,但我如何用图像替换背景替换背景?
[S O L V E D]
现在它的作品!!
[moreController.navigationBar setBackgroundImage:[UIImage imageNamed: @"navBar.png"] forBarMetrics:UIBarMetricsDefault];
解决方案
I found that this does work and has been implemented [navBar setBackgroundImage:[UIImage imageNamed: @"image.png"] forBarMetrics:UIBarMetricsDefault];
Also take a look into the Apple Docs on this https://developer.apple.com/library/ios/#documentation/uikit/reference/UINavigationBar_Class/Reference/UINavigationBar.html It gives further explanation on what and how to customise UINavigationBar. Target needs to be iOS5+
不隶属于 StackOverflow