UIScrollView视差效果动画
UIScrollView视差效果动画

效果


源码
https://github.com/YouXianMing/Animations
//
// ScrollImageViewController.m
// Animations
//
// Created by YouXianMing on 15/11/24.
// Copyright © 2015年 YouXianMing. All rights reserved.
// #import "ScrollImageViewController.h"
#import "MoreInfoView.h"
#import "UIView+SetRect.h"
#import "Math.h" static int type = ;
static int viewTag = 0x11; @interface ScrollImageViewController () <UIScrollViewDelegate> @property (nonatomic, strong) NSArray *picturesArray;
@property (nonatomic, strong) UIScrollView *scrollView;
@property (nonatomic, strong) Math *onceLinearEquation; @end @implementation ScrollImageViewController - (void)viewDidLoad { [super viewDidLoad];
} - (void)setup { [super setup]; MATHPoint pointA;
MATHPoint pointB; // Type.
if (type % == ) { pointA = MATHPointMake(, -);
pointB = MATHPointMake(self.view.width, - ); } else if (type % == ) { pointA = MATHPointMake(, -);
pointB = MATHPointMake(self.view.width, - ); } else if (type % == ) { pointA = MATHPointMake(, -);
pointB = MATHPointMake(self.view.width, + ); } else if (type % == ) { pointA = MATHPointMake(, -);
pointB = MATHPointMake(self.view.width, + );
} self.onceLinearEquation = [Math mathOnceLinearEquationWithPointA:pointA PointB:pointB]; type++; // Init pictures data.
self.picturesArray = @[[UIImage imageNamed:@""],
[UIImage imageNamed:@""],
[UIImage imageNamed:@""],
[UIImage imageNamed:@""],
[UIImage imageNamed:@""]]; // 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.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视差效果动画的更多相关文章
- 用UIScrollView产生视差效果
用UIScrollView产生视差效果 效果: 高级效果: 源码: MoreInfoView.h + MoreInfoView.m // // MoreInfoView.h // YXCell / ...
- UIScrollView视差模糊效果
UIScrollView视差模糊效果 效果 源码 https://github.com/YouXianMing/Animations // // ScrollBlurImageViewControll ...
- 用CSS3 & jQuery创建apple TV海报视差效果
用CSS和jQuery来实现它,尽量看起来和原效果一样. 最终效果图 本教程里,我将使用CSS,HTML和jQuery来创建一个近似Apple TV视差效果,如果你正在阅读,我假设你对上述三种技术都有 ...
- 使用UITableView实现图片视差效果
使用UITableView实现图片视差效果 视差效果如下: 原理: 根据偏移量计算不同的移动速度,so easy! // // RootTableViewController.h // TableVi ...
- 滚动视差效果——background-attachment
滚动视差效果的实现原理是在同一个页面上将页面元素分为多层,例如可以分为背景.内容.贴图层,在滚动页面的时候让三者滚动的速度不一,从而在人的视觉上能够形成一种立体的近似效果.最近在做一个项目wiki的时 ...
- 基于Parallax设计HTML视差效果
年关将至,给大家拜年. 最近时间充裕了一点,给大家介绍一个比较有意思的控件:Parallax.它可以用来实现鼠标移动时,页面上的元素也做偏移的视差效果.在一些有表现层次,布局空旷的页面上,用来做Hea ...
- css中的视距perspective和视差效果
概述 之前觉得2个效果很叼,一个是3D翻转效果,另一个是视差效果.今天好好的研究一下,把心得记录下来,供以后开发时参考,相信对其他人也有用. 3D翻转 3D翻转效果其实非常简单,其实就是perspec ...
- banner 跟随鼠标呈现视差效果
参考 Element 官网,利用 js / jq 和 css3, 实现某图片随着鼠标移动呈现的视差效果. <!DOCTYPE html> <html> <head> ...
- 使用NestedScrollView+ViewPager+RecyclerView+SmartRefreshLayout打造酷炫下拉视差效果并解决各种滑动冲突
使用NestedScrollView+ViewPager+RecyclerView+SmartRefreshLayout打造酷炫下拉视差效果并解决各种冲突 如果你还在为处理滑动冲突而发愁,那么你需要静 ...
随机推荐
- day6面向对象
面向对象介绍(http://www.cnblogs.com/alex3714/articles/5188179.htm) 世界万物,皆可分类 世界万物,皆为对象 只要是对象,就 ...
- php中的PDO函数库详解
PHP中的PDO函数库详解 PDO是一个“数据库访问抽象层”,作用是统一各种数据库的访问接口,与mysql和mysqli的函数库相比,PDO让跨数据库的使用更具有亲和力:与ADODB和MDB2相比,P ...
- js缓存加密
1.访问A链接就以A链接的特定部分为密码盐,生成一个js跳转配置文件名 aojoweiojoiwjeiof2.PHP在生成js跳转文件名的时候,也是根据数据库中的跳转起始链接特定部分作为盐,生成的文件 ...
- 创建 python 虚拟环境
conda 创建环境 conda 可以理解为一个工具,也是一个可执行命令,其核心功能是包管理与环境管理.包管理与 pip 的使用类似,环境管理则允许用户方便地安装不同版本的 python 并可以快速切 ...
- Java异常处理中的恢复模型
异常处理理论上有两种基本模型.Java支持终止模型,在这种模型中,假设错误非常关键,以至于程序无法返回到异常发生的地方继续执行.一旦异常被抛出,就表明错误已无法挽回,也不能回来继续执行.长久以来,尽管 ...
- IDEA导入eclipse项目并部署运行完整步骤(转发)
首先说明一下:idea里的project相当于eclipse里的workspace,而idea里的modules相当于eclipse里的project 1.File-->Import Proje ...
- 监控cpu、内存 <shell>
获取cpu.内存结果 pid=$1 #获取进程pid echo $pid interval=1 #设置采集间隔 while true do echo $(date +"%y-%m-%d %H ...
- HTTP请求的GET与POST方式的区别
Form中的get和post方法,在数据传输过程中分别对应了HTTP协议中的GET和POST方法.二者主要区别如下: 1)Get是用来从服务器上获得数据,而Post是用来向服务器上传递数据: 2)Ge ...
- Python如何将RGB图像转换为Pytho灰度图像?
我正尝试使用matplotlib读取RGB图像并将其转换为灰度.在matlab中,我使用这个: 1 img = rgb2gray(imread('image.png')); 在matplotlib t ...
- 联系表单 1_copy
你的名字 (必填) [text* your-name] 你的邮箱 (必填) [email* your-email] 主题 [text your-subject] 你的留言 [textarea your ...