天天看点

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.tintColor = [UIColor colorWithWhite:1 alpha:0.0];
    [self.navigationController.navigationBar setBackgroundImage:[UIImage imageWithColor:[UIColor colorWithWhite:1 alpha:0.0]] forBarMetrics:UIBarMetricsDefault];
    [self.navigationController.navigationBar setShadowImage:nil];
           

BaseTabBarController里设置 tabbar透明

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

    // tabbar 不透明
    self.tabBarController.tabBar.backgroundColor =[UIColor whiteColor];