美文网首页
导航栏和Tabbar分割线隐藏

导航栏和Tabbar分割线隐藏

作者: Mr周190728 | 来源:发表于2019-10-29 15:53 被阅读0次

1.navigationController:

可以在父类里面设置,也可以在部分需要隐藏的子控制器里实现 

[self.navigationController.navigationBar setShadowImage:[UIImage new]];    [self.navigationController.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];

2:Tabbar:在AppDelegate里,

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

 [[UITabBar appearance] setBarTintColor:[UIColor blackColor]];

    [[UITabBar appearance] setBackgroundImage:[self imageWithColor:[UIColor blackColor]]];

    [[UITabBar appearance] setShadowImage:[[UIImage alloc] init]];

}

-(UIImage*)imageWithColor:(UIColor*)color {

//生成输入色值的图片

    CGRectrect =CGRectMake(0.0f,0.0f,1.0f,1.0f);//宽高 1.0只要有值就够了

    UIGraphicsBeginImageContext(rect.size); //在这个范围内开启一段上下文

    CGContextRef context = UIGraphicsGetCurrentContext();

    CGContextSetFillColorWithColor(context, [color CGColor]);//在这段上下文中获取到颜色UIColor

    CGContextFillRect(context, rect);//用这个颜色填充这个上下文

    UIImage *image = UIGraphicsGetImageFromCurrentImageContext();//从这段上下文中获取Image属性,,,结束

    UIGraphicsEndImageContext();

    returnimage;

}

相关文章

网友评论

      本文标题:导航栏和Tabbar分割线隐藏

      本文链接:https://www.haomeiwen.com/subject/ztalyctx.html