2011-06-07 54 views
1

我需要在我的所有頁面中顯示導航欄下方的圖像(徽標)。跨應用程序在全球範圍內添加徽標圖像

我實現

@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

將無法​​正常工作。是走出這可能在全球範圍內使用圖像或任何其他更好的辦法?

回答

0

在AppDelegate.m添加此文件

- (BOOL)應用:(UIApplication的*)應用didFinishLaunchingWithOptions:(NSDictionary的*)launchOptions
{
navigationController = [[UINavigationController的頁頭] 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;

:)

相關問題