iOS 隐藏或改变导航栏下面的黑线样式

- (BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions {

// Override point for customization after application launch.

self.window= [[UIWindowalloc]initWithFrame:[UIScreenmainScreen].bounds];

self.window.backgroundColor= [UIColorwhiteColor];

[self.windowmakeKeyAndVisible];

ViewController*viewCon = [[ViewControlleralloc]init];

UINavigationController*navCon = [[UINavigationControlleralloc]initWithRootViewController:viewCon];

//设置导航栏背景颜色

navCon.navigationBar.barTintColor= [UIColorcolorWithRed:13.0/255green:125.0/255blue:220.0/255alpha:1];

//设置导航栏不透明,透明时,导航栏在屏幕最上层,即设置Subview的frame是加64,不透明时,导航栏与ViewController在同一层,即设置Subview的frame是不加64

[navCon.navigationBarsetTranslucent:NO];

UIImageView*navBarHairlineImageView = [selffindHairlineImageViewUnder:navCon.navigationBar];

navBarHairlineImageView.hidden=YES;

self.window.rootViewController= navCon;

returnYES;

}

//通过一个方法来找到这个黑线(findHairlineImageViewUnder):

- (UIImageView*)findHairlineImageViewUnder:(UIView*)view {

if([viewisKindOfClass:UIImageView.class] && view.bounds.size.height<=1.0) {

return(UIImageView*)view;

}

for(UIView*subviewinview.subviews) {

UIImageView*imageView = [selffindHairlineImageViewUnder:subview];

if(imageView) {

returnimageView;

}

}

returnnil;

}

你可能感兴趣的:(iOS 隐藏或改变导航栏下面的黑线样式)