我目前正在做以下事情:
BlogViewController *viewController = [[BlogViewController alloc] initWithBlogPosts];
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:viewController];
[self presentModalViewController:navController animated:YES];
[viewController release];
[navController release];
但是,我需要一种方法来使用自定义 UINavigationBar。我试过使用这样的类别:
@implementation UINavigationBar (Image)
- (void)drawRect:(CGRect)rect {
UIImage *image = [UIImage imageNamed: @"toolbar.png"];
[image drawInRect:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)];
}
@end
但它似乎并没有意识到这一点。有什么建议么? BlogViewController 是 UIViewController 的子类。
最佳答案
对于 ios5,您可以直接使用 setBackgroundImage:forBarMetrics:
设置背景图像。
保留 ios5 之前的类别实现,并检查导航栏是否响应上面的选择器,并且您已经涵盖了两个版本。
关于iphone - 将自定义 UINavigationBar 与 initAsRootViewController 一起使用 :,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8196599/