Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make UINavigationBar Transparent in IOS 8?

Tags:

ios

iphone

I have tried a lot to make UINavigationBar transparent. But I failed making it so.The image which I set was transparent. Here is my code . Any help ? Thanks in advance.

 [rootNavC.navigationBar setBackgroundImage:[UIImage imageNamed:@"NAV_BG_iphone.png"] forBarMetrics:UIBarMetricsDefault];
rootNavC.navigationBar.translucent = YES;
rootNavC.navigationBar.backgroundColor = [UIColor clearColor];
[[UINavigationBar appearance] setTitleTextAttributes:@{
                           UITextAttributeTextColor : [UIColor whiteColor],
                     UITextAttributeTextShadowColor : [UIColor clearColor],
                    UITextAttributeTextShadowOffset : [NSValue valueWithUIOffset:UIOffsetMake(0, 0)],
                                UITextAttributeFont : [UIFont fontWithName:@"pastel" size:20]
 }];
like image 957
Mounika Vangala Avatar asked Dec 01 '14 12:12

Mounika Vangala


Video Answer


2 Answers

try this

   [self.navigationController.navigationBar setBackgroundImage:[UIImage new]
                         forBarMetrics:UIBarMetricsDefault];
    self.navigationController.navigationBar.shadowImage = [UIImage new];
    self.navigationController.navigationBar.translucent = YES;
    self.navigationController.view.backgroundColor = [UIColor clearColor];

I hope the above code helps.

like image 105
Aruna kumari Avatar answered Oct 19 '22 12:10

Aruna kumari


Try adding this code. It worked for me in iOS 8.

[self.navigationController.navigationBar setTranslucent:YES];
[self.navigationController.navigationBar setBackgroundImage:[[UIImage alloc] init] forBarMetrics:UIBarMetricsDefault];
self.navigationController.navigationBar.shadowImage = [[UIImage alloc] init];
self.navigationController.navigationBar.backgroundColor = [UIColor clearColor]

Using this code, you don't even need to add your transparent UIImage. Update here if it helps you.

like image 22
Sushil Sharma Avatar answered Oct 19 '22 11:10

Sushil Sharma