Sha*_*eem 1 iphone objective-c uinavigationbar ios
如何完成UINavigationBar自定义?它是使用子类还是类别?

我对两个方面感兴趣:
在此先感谢您的帮助
对于福克斯新闻应用程序,它看起来只是设置导航栏的色调颜色.至于福克斯新闻标志,它可能只是导航栏标题视图上的图像视图.此代码进入视图控制器的viewDidLoad方法:
[self.navigationController.navigationBar setTintColor:/* Custom color here */];
UIImageView *logoView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"logo"]];
[self.navigationItem setTitleView:logoView];
[logoView release];
Run Code Online (Sandbox Code Playgroud)
要自定义后退按钮,您需要将其放在前一个视图控制器的viewDidLoad方法中(即此按钮返回的方法):
UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithTitle:@"Shows"
style:UIBarButtonItemStyleBordered target:nil action:nil];
[self.navigationItem setBackBarButtonItem:backButton];
[backButton release];
Run Code Online (Sandbox Code Playgroud)
如果要为应用程序的导航栏使用完全自定义的背景图像,则需要创建自定义UINavigationBar类别并在其drawRect:方法中绘制图像.像这样的东西:
@implementation UINavigationBar (UINavigationBarBackgroundImage)
- (void)drawRect:(CGRect)rect
{
[[UIImage imageNamed:@"navigation-bar"] drawInRect:rect];
// Optionally you can set the tintColor here to go with the background
}
@end
Run Code Online (Sandbox Code Playgroud)