IOS动画隐式,显式,翻页
// ViewController.m
// IOS动画0817
//
// Created by 张艳锋 on 15/8/17.
// Copyright (c) 2015年 张艳锋. All rights reserved.
//
#import "ViewController.h"
@interface ViewController ()
@property (weak, nonatomic) IBOutlet UIImageView *imageview;
- (IBAction)doAnimationButton:(id)sender;
- (IBAction)doLeftButton:(id)sender;
- (IBAction)doRightButton:(id)sender;
- (IBAction)doUpButton:(id)sender;
- (IBAction)doDownButton:(id)sender;
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (IBAction)doAnimationButton:(id)sender {
/********隐式动画********/
/*
[UIView beginAnimations:nil context:NULL];//动画开始标志
//定义一个仿射变换
CGAffineTransform moveTrans=CGAffineTransformMakeTranslation(300, 600);
// CGAffineTransformMakeTranslation//更改位置的函数
// CGAffineTransformMakeRotation//k控制旋转
//CGAffineTransformMakeScale//控制缩放
[_imageview.layer setAffineTransform:moveTrans];
[UIView commitAnimations];//提交动画
*/
/********显式动画********/
//定义显示动画的时候,我们不必定义CALayer的变化,也不必执行它,而是通过CABasicAnimation逐个定义动画,其中每个动画都含有各自的属性,然后通过addAnimation:方法添加到图层中
/*
CABasicAnimation *basic=[CABasicAnimation animationWithKeyPath:@"opacity"];//opacity表示透明度
basic.duration=6.0;//6秒内透明度变为零
basic.fromValue=[NSNumber numberWithFloat:0.2];//初始透明度
basic.toValue=[NSNumber numberWithFloat:1.0];//最终透明度
basic.cumulative=YES;//设置透明度递增
[_imageview.layer addAnimation:basic forKey:@"animateOpacity"];
CGAffineTransform moveTrans1=CGAffineTransformMakeTranslation(300, 600);
CABasicAnimation *basic_move=[CABasicAnimation animationWithKeyPath:@"transform"];//准备函数(为平移做准备)
basic_move.duration=6.0;
//CATransform3DMakeAffineTransform仿射变换为3D效果(仿射不能直接应用于显式动画)
basic_move.toValue=[NSValue valueWithCATransform3D:CATransform3DMakeAffineTransform(moveTrans1)];
[_imageview.layer addAnimation:basic_move forKey:@"animateTransform2"];
*/
/********关键帧动画********/
/*
CAKeyframeAnimation *keyAnimation=[CAKeyframeAnimation animationWithKeyPath:@"opacity"];//透明度
keyAnimation.duration=6.0;//动画时间
keyAnimation.values=[NSArray arrayWithObjects:[NSNumber numberWithFloat:0.0],[NSNumber numberWithFloat:0.6],[NSNumber numberWithFloat:1.0], nil];//
keyAnimation.keyTimes=[NSArray arrayWithObjects:[NSNumber numberWithFloat:0.0],[NSNumber numberWithFloat:0.3],[NSNumber numberWithFloat:1.0], nil];
[_imageview.layer addAnimation:keyAnimation forKey:@"animateOpcaty"];
CGAffineTransform moveTrans2=CGAffineTransformMakeTranslation(300, 600);
CABasicAnimation *basic_move2=[CABasicAnimation animationWithKeyPath:@"transform"];
basic_move2.duration=6.0;
basic_move2.toValue=[NSValue valueWithCATransform3D:CATransform3DMakeAffineTransform(moveTrans2)];
[_imageview.layer addAnimation:basic_move2 forKey:@"animateTransform2"];
*/
}
//系统自带反转动画(上下左右)
- (IBAction)doLeftButton:(id)sender {
//三次向左不返回
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1.5f];//动画时间
[UIView setAnimationCurve:UIViewAnimationCurveEaseOut];//设置动画曲线方式(动画的总体变化时间曲线,包含开始慢后来快,开始快后来慢,均匀曲线)
[UIView setAnimationRepeatAutoreverses:NO];//设置动画是否做一次反向操作
[UIView setAnimationRepeatCount:3];//执行次数
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.view cache:YES];//
[UIView commitAnimations];
}
- (IBAction)doRightButton:(id)sender {
//三次向右有返回
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1.5f];
[UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
[UIView setAnimationRepeatAutoreverses:YES];
[UIView setAnimationRepeatCount:3];//执行次数
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.view cache:YES];
[UIView commitAnimations];
}
- (IBAction)doUpButton:(id)sender {
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1.5f];
[UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
[UIView setAnimationRepeatAutoreverses:YES];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.view cache:YES];
[UIView commitAnimations];
}
- (IBAction)doDownButton:(id)sender {
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1.5f];
[UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
[UIView setAnimationRepeatAutoreverses:YES];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlDown forView:self.view cache:YES];
[UIView commitAnimations];
}
IOS动画隐式,显式,翻页的更多相关文章
- 第一行Kotlin系列(二)Intent隐式显式跳转及向下传值
1.Intent显式跳转页面 val button5 = findViewById<Button>(R.id.mButton5) button5.setOnClickListener { ...
- 动画:UIKitAnimation 简单动画学习 iOS (一) 渐变 、 移动 、翻页、来回翻转 ——转载
转载请说明(谢谢) http://blog.csdn.net/a21064346/article/details/7851695 点击打开链接 以下 一个系列的 动画效果 在 UIView.h文件中可 ...
- iOS如何做出炫酷的翻页效果
详情链接http://www.jianshu.com/p/b6dc2595cc3e https://github.com/schneiderandre/popping
- CALayer的隐式动画和显式动画
隐式事务 任何对于CALayer属性的修改,都是隐式事务,都会有动画效果.这样的事务会在run-loop中被提交. - (void)viewDidLoad { //初始化一个layer,添加到主视图 ...
- CoreAnimation4-隐式动画和显式动画
事务 Core Animation基于一个假设,说屏幕上的任何东西都可以(或者可能)做动画.动画并不需要你在Core Animation中手动打开,相反需要明确地关闭,否则他会一直存在. 当你改变CA ...
- 6个超炫酷的HTML5电子书翻页动画
相信大家一定遇到过一些电子书网站,我们可以通过像看书一样翻页来浏览电子书的内容.今天我们要分享的HTML5应用跟电子书翻页有关,我们精选出来的6个电子书翻页动画都非常炫酷,而且都提供源码下载,有需要的 ...
- IOS动画总结
IOS动画总结 一.基本方式:使用UIView类的UIViewAnimation扩展 + (void)beginAnimations:(NSString *)animationID context ...
- iOS动画学习 -隐式动画
事务 Core Animation基于一个假设,说屏幕上的任何东西都可以(或者可能)做动画.你并不需要在Core Animation中手动打开动画,但是你需要明确地关闭它,否则它会一直存在. 当你改变 ...
- iOS 动画基础-显式动画
摘要 显式动画 属性动画 CABasicAnimation *animation = [CABasicAnimation animation]; [self updateHandsAn ...
随机推荐
- mysql博客
http://blog.csdn.net/mchdba/article/details/9190771 本帖最后由 mchdba 于 2014-2-10 17:15 编辑 公司招聘MySQL DBA, ...
- mfc extention dll 與 normal dll 的區別
extention dll 1.指從MFC中繼承過來的DLL,一般要求使用共享MFC DLL進行連接,也要求調用者也使用MFC且使用共享MFC,如此可保證DLL與調用者有相同的MFC庫. 2.在使用資 ...
- Sublime text 2下alignment插件无效的解决办法
在sublime text 2中安装了alignment插件,但使用快捷键‘ctrl+alt+a'无效,经过各种方法依然无效,最后找到了这个“Doesn't work at all for me (f ...
- 探索多线程使用同一个数据库connection的后果
在项目中看到有用到数据库的连接池,心里就思考着为什么需要数据库连接池,只用一个连接会造成什么影响?(只用一个connection)? 1 猜想:jdbc的事务是基于connection的,如果多线程 ...
- 1.4.2 solr字段类型--(1.4.2.5)使用枚举字段
1.4.2 solr字段类型 (1.4.2.1) 字段类型定义和字段类型属性. (1.4.2.2) solr附带的字段类型 (1.4.2.3) 使用货币和汇率 (1.4.2.4) 使用Dates(日期 ...
- IOS Xcode 无法识别IOS device 突然发生的
今天 我用真机mini好好地 ,再想测试一下iphone 4 发生了意外 两个测试机都找不到设备了 但是 都在充电 还能连接 itune !!!! 我郁闷了 解决办法 是 Mac iTunes 重新 ...
- Java Set接口
Set 集合不能包含重复的元素的集合.该模型数学抽象集合. Set接口只包含继承自Collection的方法,并增加了重复的元素被禁止约束性. 集还增加了对equals和hashCode操作的行为更强 ...
- 百篇大计敬本年之系统篇《六》—— Ubuntu 16.04开启 root 超级用户
Ubuntu 16.04系统在一开始安装完成时是无法切换到 root 用户的,普通用户需要使用 root 权限的时候通常需要在执行命令前加 "sudo",需要经常使用root权限的 ...
- MSP下载方式
MSP430无论是仿真还是烧写程序,一般可以通过:JTAG.SBW.BSL接口进行. 1.JTAG是利用边界扫描技术,在430内部有逻辑接口给JTAG使用,内部有若干个寄存器连接到了430内部数据地址 ...
- 浅谈实现placeholder效果的几种方案
placeholder是html5<input>的一个属性,它提供可描述输入字段预期值的提示信息(hint), 该提示会在输入字段为空时显示.高端浏览器支持此属性(ie10/11在获得焦点 ...