iOS - 设置导航栏透明

效果图如下:


iOS - 设置导航栏透明_第1张图片
透明导航栏.png
-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    self.navigationController.navigationBar.translucent = YES; //必须将半透明设置为YES,否则好像无效
    [self.navigationController.navigationBar setBackgroundImage:[[UIImage alloc] init] forBarMetrics:UIBarMetricsDefault];
}

- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
    self.navigationController.navigationBar.translucent = NO;
}

你可能感兴趣的:(iOS - 设置导航栏透明)