21

I need a NavigationBar like in the calendar in iOS 7.

I have noticed that the NavigationBar does not have any blur behind it.

Calendar app iOS7

when going back from one detail view. It's just the "main" NavigationBar that is "normal".

Calendar app iOS7

Anyone have any idea how to do this?

I have tried to do this:

[self.navigationController.navigationBar setFrame:CGRectMake(0, 0, 320, 88)];

But this would move the title and the buttons down 44px.

I have another idea to add another navigation bar under the navigationController.navigationBar, but then I have a line under the first navigation bar. Anyone knows how to remove this?

Thanks!

4

1 回答 1

5

我修好了它!

我在“主要”导航栏下放置了另一个导航栏。删除了“主要”导航栏阴影线。

移除 NavigationBar 半透明并将背景颜色设置为 97% 白色。(这是标准的)。如果 translucent 为 YES,那么当 content 位于后面时会看起来很奇怪。

[self.navigationController.navigationBar setTranslucent:NO];
[self.navigationController.navigationBar setBarTintColor:[UIColor colorWithWhite:0.97 alpha:1]];
[NavigationBarExtension setTranslucent:NO];
[NavigationBarExtension setBarTintColor:[UIColor colorWithWhite:0.97 alpha:1]];

删除该行的代码(在 viewWillAppear 中执行此操作:因为如果您推送其他视图控制器,则该行必须返回)

- (void)viewWillAppear:(BOOL)animated {
    for (UIView *view in self.navigationController.navigationBar.subviews) {
        if ([view isKindOfClass:NSClassFromString(@"_UINavigationBarBackground")]) {
            for (UIView *view2 in view.subviews) {
                if ([view2 isKindOfClass:[UIImageView class]] && view2.frame.size.height < 1) {
                    [view2 setHidden:YES];
                    break;
                }
            }
        }
    }
}

推送其他视图控制器时显示该行的代码:

- (void)viewWillAppear:(BOOL)animated {
    for (UIView *view in self.navigationController.navigationBar.subviews) {
        if ([view isKindOfClass:NSClassFromString(@"_UINavigationBarBackground")]) {
            for (UIView *view2 in view.subviews) {
                if ([view2 isKindOfClass:[UIImageView class]] && view2.frame.size.height < 1) {
                    [view2 setHidden:NO];
                    break;
                }
            }
        }
    }
}
于 2013-09-20T21:41:22.367 回答