iOS navigationBar/tabbar背景设置为透明


UIViewController控制器里设置 导航栏透明

// 设置导航栏透明
    self.navigationController.navigationBar.translucent = YES;
    [self.navigationController.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
    [self.navigationController.navigationBar setShadowImage:[UIImage new]];

// 设置导航栏不透明
    self.navigationController.navigationBar.translucent = NO;
    self.navigationController.navigationBar.barStyle = UIBarStyleBlackOpaque;
    //self.navigationController.navigationBar.tintColor = [UIColor colorWithWhite:1 alpha:0.5];
    [self.navigationController.navigationBar setBackgroundImage:[UIImage imageWithColor:[UIColor colorWithWhite:1 alpha:0.5]] forBarMetrics:UIBarMetricsDefault];
    [self.navigationController.navigationBar setShadowImage:[UIImage imageWithColor:[UIColor colorWithWhite:0.8 alpha:0.6]]];

BaseTabBarController里设置 tabbar透明

self.tabBar.backgroundColor =[UIColor clearColor];
    [self.tabBar setBackgroundImage:[[UIImage new] imageWithColor:[UIColor clearColor]]];
    [self.tabBar setShadowImage:[UIImage new]];



猜你喜欢

转载自blog.csdn.net/wenzfcsdn/article/details/80904388