Mounika Vangala Mounika Vangala - 15 days ago 7
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

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

if (IS_OS_7_OR_LATER)
{
    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.