美文网首页
设置导航栏透明

设置导航栏透明

作者: 兜麦 | 来源:发表于2016-04-06 13:27 被阅读1602次

- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[self.navigationController.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
[self.navigationController.navigationBar setShadowImage:[UIImage new]];
}

- (void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
[self.navigationController.navigationBarsetBackgroundImage:nil forBarMetrics:UIBarMetricsDefault];
[self.navigationController.navigationBar setShadowImage:nil];
}

给UIImage增加分类设置透明

- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[self.navigationController.navigationBar setBackgroundImage:[UIImage imageWithColor:[UIColor clearColor] size:CGSizeMake(self.view.frame.size.width, 64)] forBarPosition:UIBarPositionAny barMetrics:UIBarMetricsDefault];
[self.navigationController.navigationBar setShadowImage:[UIImage new]];
}

- (void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
[self.navigationController.navigationBar setBackgroundImage:nil forBarPosition:UIBarPositionAny barMetrics:UIBarMetricsDefault];
[self.navigationController.navigationBar setShadowImage:nil];
}

+ (UIImage *)imageWithColor:(UIColor *)color size:(CGSize)size
{
if (!color || size.width <= 0 || size.height <= 0) return nil;
CGRect rect = CGRectMake(0, 0, size.width, size.height);
UIGraphicsBeginImageContextWithOptions(rect.size, NO, 0);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetFillColorWithColor(context, color.CGColor);
CGContextFillRect(context, rect);
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return image;
}

相关文章

  • 导航栏渐变隐现

    页面不显示导航栏,上托一定的距离显示导航栏. 设置导航栏存在且透明: 1.设置导航栏的透明: //导航栏透明 ...

  • Swift - NavigationBar Tips

    设置导航栏背景色为透明 隐藏导航栏下方的线条 设置导航栏的背景色 设置导航栏背景不为半透明

  • iOS 设置导航栏半透明后添加视图变化

    1.设置导航栏为不透明 2.设置导航栏为半透明 [系统默认就是半透明的]注意:iOS 导航栏如果设置为半透明,则其...

  • 导航栏

    1,设置透明导航栏: 2,设置导航栏颜色(在设置透明后设置barTintColor无效): 尽管设置了透明度但是还...

  • swift-导航栏修改高度

    导航栏直接可以通过frame来改变高度 设置导航栏半透明 设置导航栏背景图片 设置导航栏阴影图片 设置导航栏前景色...

  • iOS设置导航栏样式到AttributeString富文本总结

    一、iOS开发中导航栏设置1.1、导航栏透明的设置方法 1.2设置导航栏背景色 1.3 设置导航栏中titleLa...

  • 设置导航栏颜色, 字体大小

    取出导航栏 设置导航栏背景色 设置标题颜色和字体大小 设置布局从导航栏下开始, 把导航栏设置为不透明 设置状态栏的...

  • 导航栏设置

    设置导航栏某个界面的导航栏透明 (导航按钮显示) 在viewWillAppear里面加两行代码 //设置导航栏背景...

  • iOSAttributeString 属性总结

    一、iOS开发中导航栏设置 1.1、导航栏透明的设置方法 //1.1.1 在具有导航栏的viewControlle...

  • Swift Develop Tips

    1、设置导航栏为透明

网友评论

      本文标题:设置导航栏透明

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