如何使导航栏背景颜色为clearColor?

时间:2015-05-11 03:17:04

标签: ios objective-c uinavigationcontroller uinavigationbar uinavigationitem

我的个人资料视图控制器嵌入在导航控制器中,并显示彩色导航栏。但我想避免那种或如何使导航栏背景颜色为clearColor。这样它就可以显示下面的图像,例如。推特应用

6 个答案:

答案 0 :(得分:1)

试试这段代码:

[self.navigationBar setBackgroundImage:[UIImage new]
                         forBarMetrics:UIBarMetricsDefault];
self.navigationBar.shadowImage = [UIImage new];
self.navigationBar.translucent = YES;
self.navigationController.navigationBar.tintColor = [UIColor clearColor];
self.navigationController.navigationBar.backgroundColor = [UIColor clearColor];

答案 1 :(得分:0)

非常样品, 你可以尝试:

YourNavigation.navigationBar.barTintColor = [UIColor clearColor];

YourNavigation:输入您的NavigationController。

如果这有帮助,你可以为我加油!

由于

答案 2 :(得分:0)

试试这个

   self.navigationBar.setBackgroundImage(UIImage(), forBarMetrics: UIBarMetrics.Default)
   self.navigationBar.shadowImage = UIImage()
   self.navigationBar.translucent = true

in swift

    - (void)viewDidLoad
{
    _childViewController = [[WeeklyViewController alloc]init];
    self.delegate = _childViewController;
    [self addChildViewController:_childViewController];
    [self.view addSubview:_childViewController.view];
    [_childViewController didMoveToParentViewController:self];
}

答案 3 :(得分:0)

将此行放在AppDelegate的didFinsihLaunchingWithOptions:

    [[UINavigationBar appearance] setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault]; // This is for clear navigation bar 
    [[UINavigationBar appearance] setShadowImage:[UIImage new]]; // this for remvove line under the navigationbar

答案 4 :(得分:0)

[self.navigationController.navigationBar setBackgroundImage:[UIImage new]
                                              forBarMetrics:UIBarMetricsDefault];
self.navigationController.navigationBar.shadowImage = [UIImage new];
self.navigationController.navigationBar.translucent = YES;
self.navigationController.view.backgroundColor = [UIColor clearColor];
self.navigationController.navigationBar.backgroundColor = [UIColor clearColor];

答案 5 :(得分:-1)

您无法使导航栏清晰。只需添加自定义视图,然后将其清除。