UIScrollView视差模糊效果

效果

源码

https://github.com/YouXianMing/Animations

//
// ScrollBlurImageViewController.m
// Animations
//
// Created by YouXianMing on 15/11/25.
// Copyright © 2015年 YouXianMing. All rights reserved.
// #import "ScrollBlurImageViewController.h"
#import "MoreInfoView.h"
#import "UIView+SetRect.h"
#import "Math.h"
#import "UIImage+ImageEffects.h" static int viewTag = 0x11; @interface ScrollBlurImageViewController () <UIScrollViewDelegate> @property (nonatomic, strong) NSArray *picturesArray;
@property (nonatomic, strong) UIScrollView *scrollView;
@property (nonatomic, strong) Math *onceLinearEquation; @end @implementation ScrollBlurImageViewController - (void)viewDidLoad { [super viewDidLoad];
} - (void)setup { [super setup]; MATHPoint pointA = MATHPointMake(, -);
MATHPoint pointB = MATHPointMake(self.view.width, self.view.width - );; self.onceLinearEquation = [Math mathOnceLinearEquationWithPointA:pointA PointB:pointB]; // Init pictures data.
self.picturesArray = @[[UIImage imageNamed:@"beauty"],
[[UIImage imageNamed:@"beauty"] blurImage],
[[UIImage imageNamed:@"beauty"] grayScale]]; // Init scrollView.
CGFloat height = self.view.height;
CGFloat width = self.view.width; _scrollView = [[UIScrollView alloc] initWithFrame:self.view.bounds];
_scrollView.delegate = self;
_scrollView.pagingEnabled = YES;
_scrollView.backgroundColor = [UIColor blackColor];
_scrollView.showsHorizontalScrollIndicator = NO;
_scrollView.bounces = NO;
_scrollView.contentSize = CGSizeMake(self.picturesArray.count * width, height);
[self.view addSubview:_scrollView]; // Init moreInfoViews.
for (int i = ; i < self.picturesArray.count; i++) { MoreInfoView *show = [[MoreInfoView alloc] initWithFrame:CGRectMake(i * width, , width, height)];
show.imageView.image = self.picturesArray[i];
show.layer.borderWidth = 0.25f;
show.layer.borderColor = [[UIColor grayColor] colorWithAlphaComponent:0.25f].CGColor;
show.tag = viewTag + i; [_scrollView addSubview:show];
} [self bringTitleViewToFront];
} - (void)scrollViewDidScroll:(UIScrollView *)scrollView { CGFloat X = scrollView.contentOffset.x; for (int i = ; i < self.picturesArray.count; i++) { MoreInfoView *show = [scrollView viewWithTag:viewTag + i];
show.imageView.x = _onceLinearEquation.k * (X - i * self.view.width) + _onceLinearEquation.b;
}
} @end

细节

UIScrollView视差模糊效果的更多相关文章

  1. UIScrollView视差效果动画

    UIScrollView视差效果动画 效果 源码 https://github.com/YouXianMing/Animations // // ScrollImageViewController.m ...

  2. iOS、mac开源项目及库汇总

    原文地址:http://blog.csdn.net/qq_26359763/article/details/51076499    iOS每日一记------------之 中级完美大整理 iOS.m ...

  3. iOS开发常用第三方库

    UI 动画 网络相关 Model 其他 数据库 缓存处理 PDF 图像浏览及处理 摄像照相视频音频处理 响应式框架 消息相关 版本新API的Demo 代码安全与密码 测试及调试 AppleWatch ...

  4. IOS常用第三方库《转》

    UI 动画 网络相关 Model 其他 数据库 缓存处理 PDF 图像浏览及处理 摄像照相视频音频处理 响应式框架 消息相关 版本新API的Demo 代码安全与密码 测试及调试 AppleWatch ...

  5. iOS常用第三方库大全,史上最全第三方库收集

    下拉刷新 EGOTableViewPullRefresh – 最早的下拉刷新控件. SVPullToRefresh – 下拉刷新控件. MJRefresh – 仅需一行代码就可以为UITableVie ...

  6. 最全面的iOS和Mac开源项目和第三方库汇总

    标签: UI 下拉刷新 EGOTableViewPullRefresh – 最早的下拉刷新控件. SVPullToRefresh – 下拉刷新控件. MJRefresh – 仅需一行代码就可以为UIT ...

  7. iOS酷炫动画效果合集

    iOS酷炫动画效果合集 源码地址 https://github.com/YouXianMing/Animations 效果绝对酷炫,包含了多种多样的动画类型,如POP.Easing.粒子效果等等,虽然 ...

  8. Swift - 用UIScrollView实现视差动画效果

    Swift - 用UIScrollView实现视差动画效果 效果 源码 https://github.com/YouXianMing/Swift-Animations // // MoreInfoVi ...

  9. 用UIScrollView产生视差效果

    用UIScrollView产生视差效果 效果: 高级效果: 源码: MoreInfoView.h  +  MoreInfoView.m // // MoreInfoView.h // YXCell / ...

随机推荐

  1. HTML--1

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  2. jquery获取浏览器宽高

    满足获取各种高的需求 $(document).ready(function() { alert($(window).height()); //浏览器时下窗口可视区域高度 alert($(documen ...

  3. easyui tree tabs

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...

  4. CSUOJ 1826 Languages map+stringstream

    Description The Enterprise has encountered a planet that at one point had been inhabited. The onlyre ...

  5. spring4声明式事务—02 xml配置方式

    1.配置普通的 controller,service ,dao 的bean. <!-- 配置 dao ,service --> <bean id="bookShopDao& ...

  6. python中的urlencode和urldecode

    python将字符串转化成urlencode ,或者将url编码字符串decode的方法: 方法1: urlencode:urllib中的quote方法 >>> from urlli ...

  7. Django小知识点整理

    一.Django中Choices字段显示中文的两种方式 1.get_xxxx_display():这种方式只能针对对象来使用 {% for row in server_list %} <li&g ...

  8. 【CF 453A】 A. Little Pony and Expected Maximum(期望、快速幂)

    A. Little Pony and Expected Maximum time limit per test 1 second memory limit per test 256 megabytes ...

  9. cdoj 841 休生伤杜景死惊开 逆序数/树状数组

    休生伤杜景死惊开 Time Limit: 3000/1000MS (Java/Others)     Memory Limit: 65535/65535KB (Java/Others) 陆伯言军陷八卦 ...

  10. 自动化运维工具 ~puppet~

    一.模板的应用 到目前为止,资源申报.定义类.声明类等所有功能都只能一个manifest文件中实现,但这却非有效的基于puppet管理IT资源架构的方式.实践 中,一般需要把manifest文件分解成 ...