2016-08-29 12 views
0

NavigationBarに描画されていない部分を設定した後で、ナビゲーションバーのViewControllerに画像を設定しようとしています。 なぜ起こったのか理解できません。UINavigationBarセットイメージが完全に描画されていません

画像サイズは90、高さと幅750

は、任意の上の私は何をする必要があるかを知らせることができますか?

[self.navigationController setToolbarHidden:YES animated:NO]; 
self.title = NSLocalizedString(@"Dashboar", @"Dashboard"); 
self.navigationController.navigationBar.barTintColor = [UIColor whiteColor]; 
self.navigationController.navigationBar.titleTextAttributes = @{NSForegroundColorAttributeName : [UIColor whiteColor]}; 
UIImage *currentImage = [[UIImage imageNamed:@"bg.png"] 
          resizableImageWithCapInsets:UIEdgeInsetsMake(0, 0, 0, 0) resizingMode:UIImageResizingModeStretch]; 
[self.navigationController.navigationBar setBackgroundImage:currentImage forBarMetrics:UIBarMetricsDefault]; 

enter image description here

+1

ナビゲーションバーの半透明のプロパティを変更すると何か変更されますか? –

+0

@TejaNandamuriありがとうございます、私はそれが仕事を無効にします。 – KkMIW

答えて

0

それは半透明のプロパティがYESで、デフォルトで7+のiOSからは、半透明の問題のように見えます。

self.navigationBar.translucent = NO; 
1
[self.navigationController setToolbarHidden:YES animated:NO]; 
self.title = NSLocalizedString(@"Dashboar", @"Dashboard"); 
self.navigationController.navigationBar.barTintColor = [UIColor whiteColor]; 
self.navigationController.navigationBar.titleTextAttributes = @{NSForegroundColorAttributeName : [UIColor whiteColor]}; 

ことによってそれを無効にしますが、複数のデバイスのために、この背景画像の幅を正確に設定する必要があります。

if (IS_IPHONE4) { 
[navController.navigationBar setBackgroundImage:[UIImage imageNamed:@"TopBar_iphone4.png"] forBarMetrics:UIBarMetricsDefault]; 
} 
if (IS_IPHONE5) { 
[navController.navigationBar setBackgroundImage:[UIImage imageNamed:@"TopBar_iphone5.png"] forBarMetrics:UIBarMetricsDefault]; 
} 
if (IS_IPHONE6) { 
[navController.navigationBar setBackgroundImage:[UIImage imageNamed:@"TopBar_iphone6.png"] forBarMetrics:UIBarMetricsDefault]; 
} 
if (IS_IPHONE6Plus) { 
[navController.navigationBar setBackgroundImage:[UIImage imageNamed:@"TopBar_iphone6plus.png"] forBarMetrics:UIBarMetricsDefault]; 
} 
    [[UINavigationBar appearance] setBackgroundImage:NavigationPortraitBackground forBarMetrics:UIBarMetricsDefault]; 

私はこのコードの仕事をチェックする必要があります。

+0

私のために働いていない! – kiran

関連する問題