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. win7上搭建ruby开发环境

    1. 安装ruby 可使用windows下的ruby安装工具rubyinstaller来方便地安装ruby解释器,可以http://rubyinstaller.org/网站上下载得到.安装时,看清安装 ...

  2. chrome护眼模式

    chrome护眼模式 使用stylish插件: 学习:https://jingyan.baidu.com/article/b907e627f74df146e6891c67.html 插件下载:http ...

  3. python使用pickle,json等序列化dict

    import pickle, json, csv, os, shutil class PersistentDict(dict): ''' Persistent dictionary with an A ...

  4. Rails时间扩展方法

    1.时间扩展方法: beginning_of_day,end_of_day等等 Time.now.end_of_day 2.ruby类型判断 is_a?(类型) 如:b.is_a?(Array)

  5. 改动Androidproject的名称(非Eclipse重命名)

    问题背景 在Eclipse,Import新的Android源代码project时.假设Eclipse的workspace已经存在同样名称project,是无法导入的. 网上有非常多改动工程名的方法.是 ...

  6. Oracle安装过程中的几点注意

    为追求统一,安装了oracle 11g step 4时需要改一下名称,利于记忆 数据库安装完之后需要取消SCOTT账户的锁定 完成后点击SQL Developer会出现——"应用程序开发&q ...

  7. 《Mining the Web:Transforming Customer Data into Customer Value》读后札记

    <Mining the Web:Transforming Customer Data into Customer Value> <Web数据挖掘:将客户数据转化为客户价值> — ...

  8. 【MyBatis学习09】高级映射之一对多查询

    上一篇博文总结了一下一对一的映射,本文主要总结一下一对多的映射,从上一篇文章中的映射关系图中可知,订单项和订单明细是一对多的关系,所以本文主要来查询订单表,然后关联订单明细表,这样就有一对多的问题出来 ...

  9. Nginx开发从入门到精通 nginx平台初探

    初探nginx架构(100%) 众所周知,nginx性能高,而nginx的高性能与其架构是分不开的.那么nginx究竟是怎么样的呢?这一节我们先来初识一下nginx框架吧. nginx在启动后,在un ...

  10. linux后台运行命令

    Ctrl+z/bg/nohup/setsid/& screen 区别待续