在整个应用程序中全局添加徽标图像到iphone

时间:2011-06-07 07:06:25

标签: iphone objective-c

我需要在所有页面的导航栏下方显示图像(徽标)。

我正在实施

 @implementation UINavigationBar (CustomImage)  
 (void)drawRect:(CGRect)rect 
 {  
     UIImage *image = [UIImage imageNamed: @"logo.png"];  
     [image drawInRect:CGRectMake(self.frame.size.width/2, 40, 89, 42)];  
 }    
在appdelegate中 它无法解决。这可能是全局使用图像还是其他更好的方式?

1 个答案:

答案 0 :(得分:0)

在AppDelegate.m文件中添加

  

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
  {
  navigationController = [[UINavigationController alloc] initWithRootViewController:viewController];
  [self.window addSubview:navigationController.view];
  UIImageView * mImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@“apple_small_icon”]];
  [mImage setFrame:CGRectMake(270,5,35,35)];
  [navigationController.navigationBar addSubview:mImage];
  [mImage release];
  }

在AppDelegate.h文件中添加

  

UINavigationController * navigationController;

:)