How to make UINavigationBar Transparent in IOS 8?

后端 未结 6 1246
醉话见心
醉话见心 2021-01-05 14:09

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.

6条回答
  •  死守一世寂寞
    2021-01-05 14:57

    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.

提交回复
热议问题