简体   繁体   中英

UINavigation bar bottom line appears after UISearchDisplayController

I have Navigation bar, with segmented control under it and it looks like this:

在此处输入图片说明

So there is no bottom line since i removed it this way:

 for (UIView *view in self.navigationBar.subviews) {
        for (UIView *view2 in view.subviews) {
            if ([view2 isKindOfClass:[UIImageView class]]) {
                [view2 removeFromSuperview];
            }
        }
    }

But when i open Archive ViewController, that contains UISearchDisplayController, and i start searching i get normal uisearchDisplayController screen like this:

在此处输入图片说明

Now, when i Click cancel and go back to "Home" ViewController, bottom line appears again:

在此处输入图片说明

It's weird, if i just go back from Archive to Home, without opening SearchController it doesnt appear.

I tried removing bottom line in ViewDidAppear in "Home" ViewController same way as i posted above, but it's kinda late, line appears first then disappears after 1-2 seconds. I Also tried setting navigation bar shadow image to nil and it didn't do the job.

So my question is how to remove it after appearing again, any idea where should i call method i have for removing it?

in your AppDelegate.m write this code hope that will help you.

  - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
        // Override point for customization after application launch.

        [[UINavigationBar appearance] setBackgroundImage:[[UIImage alloc] init] forBarPosition:UIBarPositionAny barMetrics:UIBarMetricsDefault]; 
        [[UINavigationBar appearance] setShadowImage:[UIImage new]];

    return YES;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM