博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
IOS上路_13-简单示例-高级动画
阅读量:6246 次
发布时间:2019-06-22

本文共 4506 字,大约阅读时间需要 15 分钟。

hot3.png

1.创建SingleView项目:

    1)IOS,SingleView:

    2)UseAutomaticReferenceCounting:

2.添加依赖框架:

    1)项目,BuildPhases,LBWL:

    2)QuartzCore.framework:

3.添加演出用的图片:

4.声明演员:

5.创建舞台:

    1)放入两组按钮和4个ImageView:

    2)添加关联:

    3)设置演员:

6.初始化演出方案:

////  CVUViewController.m//  0716-AnimationAdvanced////  Created by vigiles on 13-7-16.//  Copyright (c) 2013年 vigiles. All rights reserved.//#import "CVUViewController.h"@interface CVUViewController ()@end@implementation CVUViewController/* 上面的4个按钮控制的动画 */-(IBAction)doAnimationPaper:(id)sender{    //不适用QuartzCore    //1.配置    CGContextRef context = UIGraphicsGetCurrentContext();    //2.播放    [UIView beginAnimations:nil context:context];    //3.缓动    [UIView setAnimationCurve:UIViewAnimationCurveEaseOut];    //4.时长    [UIView setAnimationDuration:1];    //5.类型    NSString * title = [sender titleForState:UIControlStateNormal];    //6.如果点击“left”按钮    if ([title isEqualToString:@"left"]) {        [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.view cache:YES];    }    if ([title isEqualToString:@"right"])    {        [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.view cache:YES];    }    if ([title isEqualToString:@"up"])    {        [UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.view cache:YES];    }    if ([title isEqualToString:@"down"])    {        [UIView setAnimationTransition:UIViewAnimationTransitionCurlDown forView:self.view cache:YES];    }    //7.演员编号    NSInteger one = [[self.view subviews]indexOfObject:self.imgViewOne];    NSInteger two = [[self.view subviews]indexOfObject:self.imgViewTwo];    NSInteger three = [[self.view subviews]indexOfObject:self.imgViewThree];    NSInteger four = [[self.view subviews]indexOfObject:self.imgViewFour];    //8.按编号切换顺序    [self.view exchangeSubviewAtIndex:one withSubviewAtIndex:two];    [self.view exchangeSubviewAtIndex:two withSubviewAtIndex:three];    [self.view exchangeSubviewAtIndex:three withSubviewAtIndex:four];    //9.委托    [UIView setAnimationDelegate:self];    //10.关闭    [UIView commitAnimations];    }/* 下面的4个按钮控制的动画 */-(IBAction)doAnimationAdvan:(id)sender{    //1.创建一个动画对象    CATransition * trsCube = [CATransition animation];    //2.委托    trsCube.delegate=self;    //3.时间    trsCube.duration=1;        //4.缓动。以下的效果似乎没差别    //trsCube.timingFunction=[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut];    //trsCube.timingFunction=[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn];    //trsCube.timingFunction=[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];    trsCube.timingFunction=[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];    //trsCube.timingFunction=[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionDefault];        //5.类型,type    trsCube.type=@"cube";   //立方体,分上下左右    //trsCube.type=@"suckEffect";   //吸收    //trsCube.type=@"oglFlip";  //翻转    //trsCube.type=@"rippleEffect"; //波纹    //trsCube.type=@"pageCurl"; //翻页    //trsCube.type=@"pageUnCurl";   //反翻页    //trsCube.type=kCATransitionFade;   //淡化    //trsCube.type=kCATransitionPush;   //推挤    //trsCube.type=kCATransitionReveal;   //揭开    //trsCube.type=kCATransitionMoveIn;   //覆盖    //trsCube.type=@"cameraIrisHollowOpen";   //镜头开        //6.方向,subtype    NSString * title = [sender titleForState:UIControlStateNormal];    if ([title isEqualToString:@"left"]) {        trsCube.subtype=kCATransitionFromLeft;    }    if ([title isEqualToString:@"right"])    {        trsCube.subtype=kCATransitionFromRight;    }    if ([title isEqualToString:@"top"])    {        trsCube.subtype=kCATransitionFromTop;    }    if ([title isEqualToString:@"down"])    {        trsCube.subtype=kCATransitionFromBottom;    }    //7. 4个演员的编号    NSInteger one = [[self.view subviews]indexOfObject:self.imgViewOne];    NSInteger two = [[self.view subviews]indexOfObject:self.imgViewTwo];    NSInteger three = [[self.view subviews]indexOfObject:self.imgViewThree];    NSInteger four = [[self.view subviews]indexOfObject:self.imgViewFour];    //8.切换顺序    [self.view exchangeSubviewAtIndex:one withSubviewAtIndex:two];    [self.view exchangeSubviewAtIndex:two withSubviewAtIndex:three];    [self.view exchangeSubviewAtIndex:three withSubviewAtIndex:four];    //[self.view exchangeSubviewAtIndex:four withSubviewAtIndex:one];   //禁止    //9.开播创建的动画    [[self.view layer] addAnimation:trsCube forKey:@"trsCube"];}@end

7.演出:

- end 

转载于:https://my.oschina.net/vigiles/blog/144891

你可能感兴趣的文章
《iOS 8开发指南》——第6章,第6.5节实战演练——使用模板Single View Application...
查看>>
【观点】离开了信息化,大数据就是为他人作嫁衣
查看>>
《HTML5+CSS3网页设计入门必读》——1.4 分裂:WHATWG TF
查看>>
《JavaScript核心概念及实践》——第2章 基本概念 2.1 数据类型
查看>>
Linux有问必答:如何修复"fatal error: jsoncpp/json/json.h: No such file..."
查看>>
阿里数据库内核月报:2016年11月
查看>>
简单了解Disruptor(一)
查看>>
编写更好 Bash 脚本的 8 个建议
查看>>
Mavens实战 1.5小结
查看>>
《 硬件创业:从产品创意到成熟企业的成功路线图》——第1章 硬件创业概述 1.1 早期的创客们...
查看>>
《Android游戏开发详解》——第3章,第3.5节继承
查看>>
《Docker生产环境实践指南》——2.6 编排
查看>>
Docker学习(一)
查看>>
云端架美购,精品零距离
查看>>
Java设计模式--享元模式
查看>>
码栈开发手册(五)---可视化方式开发(模块详解--浏览图)
查看>>
每天一个设计模式之装饰者模式
查看>>
基于自定义日志打印的UDAF调试
查看>>
JVM源码分析之Metaspace解密
查看>>
CSS 各种定位(position)方式的区别
查看>>