1、毛玻璃实现

iOS8以上,官方提供了系统方法实现毛玻璃,代码如下:

// iOS8 UIVisualEffectView
UIImageView *bgView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"car.png"]];
bgView.frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height);
[self.view addSubview:bgView];
UIVisualEffectView *blurView = [[UIVisualEffectView alloc] initWithEffect:[UIBlurEffect effectWithStyle:UIBlurEffectStyleLight]];
blurView.alpha = 0.9; // 控制模糊程度
blurView.frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height);
[bgView addSubview:blurView]; UIVibrancyEffect *vibrancyView = [UIVibrancyEffect effectForBlurEffect:(UIBlurEffect *)blurView.effect];
UIVisualEffectView *visualEffectView = [[UIVisualEffectView alloc] initWithEffect:vibrancyView];
visualEffectView.translatesAutoresizingMaskIntoConstraints = NO;
[blurView.contentView addSubview:visualEffectView];

a> UIBlurEffectStyle = UIBlurEffectStyleExtraLight;

 
Paste_Image.png

b> UIBlurEffectStyle = UIBlurEffectStyleLight;

 
Paste_Image.png

c> UIBlurEffectStyle = UIBlurEffectStyleDark;

 
Paste_Image.png
2、导航栏滑动渐变

导航栏最开始的状态是透明的状态,可以看到后面的图片。之后随着用户的滑动颜色开始加深。
代码如下:

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

在tableview或scrollview的代理方法中:

- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
CGFloat minAlphaOffset_Y = - 64;
CGFloat maxAlphaOffset_Y = 125;
CGFloat offset_Y = scrollView.contentOffset.y;
CGFloat alpha = (offset_Y - minAlphaOffset_Y) / (maxAlphaOffset_Y - minAlphaOffset_Y);
[[[self.navigationController.navigationBar subviews] objectAtIndex:0] setAlpha:alpha];
}

但是在跳转的时候需要恢复原状,即导航栏呈现不透明状态,可以封装跳转方法:

- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated{
[[[self.navigationController.navigationBar subviews] objectAtIndex:0] setAlpha:1];
[self.navigationController pushViewController:viewController animated:animated];
}

 

iOS-毛玻璃、navigationBar滑动颜色渐变的更多相关文章

  1. iOS 动画绘制线条颜色渐变的折线图

    效果图 .................... 概述 现状 折线图的应用比较广泛,为了增强用户体验,很多应用中都嵌入了折线图.折线图可以更加直观的表示数据的变化.网络上有很多绘制折线图的demo,有 ...

  2. ios显示艺术字字体颜色渐变

    UIColor * myColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"123.jpg"]]; self. ...

  3. iOS开发之创建颜色渐变视图View

    在iOS开发中有时需要自己自定义一个视图view的背景,而网上有人提出的在循环中不断alloc的方法设置其背景色渐变,会耗费很多内存和资源,极其不明智,而在CALayer中早就提供有图层渐变的类和相应 ...

  4. 【iOS开发系列】颜色渐变

    记录: //Transparent Gradient Layer - (void) insertTransparentGradient { UIColor *colorOne = [UIColor c ...

  5. IOS导航栏颜色渐变与常用属性

    (转:http://www.cnblogs.com/Lingchen-start/archive/2015/10/23/4904361.html) 今年很忙,忙的写日志的时间都很少.  少的可怜. 自 ...

  6. IOS之UI--动态设置NavigationBar的颜色以及透明度

    前言:有时候我们需要设置UINavigationController的导航条NavigationBar的颜色为透明度,这时候就需要使用到NavigationBar的barStyle这个属性: 再看QQ ...

  7. WPF 背景颜色渐变的滑动条实现

    原文:WPF 背景颜色渐变的滑动条实现 版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.csdn.net/BYH371256/article/details/83507 ...

  8. 【iOS实现一个颜色渐变的弧形进度条】

    在Github上看到一些进度条的功能,都是通过Core Graph来实现.无所谓正确与否,但是开发效率明显就差很多了,而且运行效率还是值得考究的.其实使用苹果提供的Core Animation能够非常 ...

  9. iOS 之使用CAShapeLayer中的CAGradientLayer实现圆环的颜色渐变

    本文转载自:http://blog.csdn.net/zhoutao198712/article/details/20864143 在 Github上看到一些进度条的功能,都是通过Core Graph ...

随机推荐

  1. Heartbleed漏洞利用程序

    #!/usr/bin/python # Quick and dirty demonstration of CVE-2014-0160 by Jared Stafford (jspenguin@jspe ...

  2. PHP测试用例-前言 1

    前提知识准备 在学习本课程之前,你需要准备以下知识点: 掌握一般的PHP开发技能,使用面向对象的框架开发过三个月以上 会一些JS知识 了解http协议 拥有以下知识会学得更加顺利: 掌握PHPUnit ...

  3. android 开发者的个人博客集

    1.  http://stormzhang.com/posts.html    //不少的好的工具与建议

  4. cocos2d-之音乐背景播放

    1.先加入头文件 #include <SimpleAudioEngine.h> using namespace CocosDenshion;//为了方便以下的函数使用,使用命名空间 2.在 ...

  5. docker入门——简介

    从这里起航 本系列有感于<第一本Docker书>,当我拿到这本书时感觉如获至宝. 为了培养自己对docker的兴趣,不断鞭策自己,我决定开始写这个系列的博客——<站在蓝鲸的背上思考& ...

  6. 在LoadRunner中设置HTTP请求time-out的时间

    Error -27728: Step download timeout (120 seconds) has expired when downloading non-resource(s) [MsgI ...

  7. java8 环境变量设置

    Java8环境变量配置:a.JAVA_HOME:jdk安装目录b.CLASSPATH:.;%JAVA_HOME%\libc.PATH:%JAVA_HOME%\bin配置环境变量方法:1.点击计算机,右 ...

  8. C++ 字符串转化成浮点型

    第一种: char  szString[] = "3.1415926535898"; double db1; db1 = atof(szString); printf(" ...

  9. openerp所用QWEB2的调试笔记

    [1] 调式qweb模板时, 可以脱离openerp环境 阅读一下openerp目录 qweb目录中的几个html文件,可以作为起步 在浏览器下, 可以这样运行这些文件 http://127.0.0. ...

  10. ftp mybatis

    c# 字符串和Ascii码转换http://www.cnblogs.com/JoshuaDreaming/archive/2010/11/19/1882068.html ftp 公式 http://w ...