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打造酷炫下拉视差效果并解决各种冲突 如果你还在为处理滑动冲突而发愁,那么你需要静 ...
随机推荐
- 将DataTable转换为List,将List转换为DataTable的实现类
将DataTable转换为List,将List转换为DataTable的实现类 public static class DataTableHelper { public static DataTabl ...
- XML&反射
本节内容: XML DTD约束 Schema约束 dom4j解析 反射 为了实现访问不同路径(/hello)执行不同的资源(HelloMyServlet),我们需要使用XML进行配置:为了限定XML内 ...
- Android Studio 升级为3.1 踩到的坑
原文:https://blog.csdn.net/xiariluoxue/article/details/80050700 AndroidStudio.gradle.buildToolsVersion ...
- require demo 记录备份
预览地址 http://127.0.0.1:8020/requireDemo/myNEW/index.html 注意 远程的 非模块的 empty: demo2
- python 字符串截断
>>> s = '%20and%201=2%20union%20select%201,group_concat%28table_name%29,3,4,5,6,7,8,9,10,11 ...
- LoadRunner中log的使用总结
LoadRunner中log的使用总结 1.log的设置方式. 在 runtime setting中可以设置log的生成方式: 默认的log方式: Enable logging选中,log optio ...
- console在ie下不兼容的问题(console在ie9下阻碍页面的加载,打开页面一片空白)
在页面中加入以下代码: window.console = window.console || (function() { var c = {}; c.log = c.warn = c.debug = ...
- CAS和Synchronized
CAS compareAndSwap 原理 CAS(V,E,N) V表示要更新的变量 E表示预期值 N表示新值 (当前值和底层值一样时候,才更新) 传入的值是工作内存,底层的值是主内存,工作内 ...
- 如何保证Redis中的数据都是热点数据
redis 内存数据集大小上升到一定大小的时候,就会施行数据淘汰策略.redis 提供 6种数据淘汰策略:volatile-lru:从已设置过期时间的数据集(server.db[i].expires) ...
- Visual Studio 2017强制更新方法
Visual Studio 2017强制更新方法 Visual Studio 2017更新时候,用户都是根据消息提示,进行更新.这样做的好处,就是微软可以分批下发升级包,避免集中更新.不过为了早点 ...