Mounika Vangala Mounika Vangala - 1 year ago 90
iOS Question

How to make UINavigationBar Transparent in IOS 8?

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]

Answer Source

Thanks all. The thing is that I am adding this line in my view controller:

    self.edgesForExtendedLayout = UIRectEdgeNone;
    self.extendedLayoutIncludesOpaqueBars = NO;
    self.automaticallyAdjustsScrollViewInsets = NO;

that is why the code is not working. When I remove the line

self.edgesForExtendedLayout = UIRectEdgeNone;

the code works.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download