● UIKit直接将动画集成到UIView类中,当内部的一些属性发生改变时,UIView 将为这些改变提供动画支持
● 执行动画所需要的工作由UIView类自动完成,但仍要在希望执行动画时通知视 图,为此需要将改变属性的代码放在[UIView beginAnimations:nil context:nil]和 [UIView commitAnimations]之间
 
● 常见方法解析:
● + (void)setAnimationDelegate:(id)delegate 设置动画代理对象,当动画开始或者结束时会发消息给代理对象
 
● + (void)setAnimationWillStartSelector:(SEL)selector 当动画即将开始时,执行delegate对象的selector,并且把beginAnimations:context:中 传入的参数传进selector
 
● + (void)setAnimationDidStopSelector:(SEL)selector 当动画结束时,执行delegate对象的selector,并且把beginAnimations:context:中传入 的参数传进selector
 
● + (void)setAnimationDuration:(NSTimeInterval)duration 动画的持续时间,秒为单位
● + (void)setAnimationDelay:(NSTimeInterval)delay
动画延迟delay秒后再开始

● + (void)setAnimationStartDate:(NSDate *)startDate
动画的开始时间,默认为now

● + (void)setAnimationCurve:(UIViewAnimationCurve)curve
动画的节奏控制,具体看下面的”备注”

● + (void)setAnimationRepeatCount:(float)repeatCount
动画的重复次数

● + (void)setAnimationRepeatAutoreverses:(BOOL)repeatAutoreverses
如果设置为YES,代表动画每次重复执行的效果会跟上一次相反

● + (void)setAnimationTransition:(UIViewAnimationTransition)transition forView:(UIView *)view cache:(BOOL)cache 设置视图view的过渡效果, transition指定过渡类型, cache设置YES代表使用视 图缓存,性能较好
#import "NJViewController.h"

@interface NJViewController ()
@property (weak, nonatomic) IBOutlet UIView *cutomView; @end @implementation NJViewController - (void)viewDidLoad
{
[super viewDidLoad]; }
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{ [UIView transitionWithView:self.view duration:1.0 options: animations:^{
NSLog(@"animations");
// 要执行的动画
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.view cache:YES]; } completion:^(BOOL finished) {
NSLog(@"completion");
// 执行完毕之后执行的动画
}]; } - (void)test2
{
[UIView animateWithDuration:2.0 animations:^{
NSLog(@"动画执行之前: %@",NSStringFromCGPoint(self.cutomView.center));
// 需要执行动画的代码
self.cutomView.center = CGPointMake(, ); } completion:^(BOOL finished) {
// 动画执行完毕之后执行的代码
NSLog(@"动画执行之后: %@",NSStringFromCGPoint(self.cutomView.center)); }];
} - (void)test1
{
// 1.创建核心动画
// 注意点:如果通过核心动画改变layer的位置状态, 表面上看上去已经改变了, 但是实质上是没有改变的
CABasicAnimation *anima = [CABasicAnimation animation];
anima.keyPath = @"position";
anima.toValue = [NSValue valueWithCGPoint:CGPointMake(, )]; anima.removedOnCompletion = NO;
anima.fillMode = kCAFillModeForwards; anima.delegate = self; // 2.添加核心动画
[self.cutomView.layer addAnimation:anima forKey:nil];
} - (void)animationDidStart:(CAAnimation *)anim
{
NSLog(@"核心动画执行之前 %@", NSStringFromCGPoint(self.cutomView.layer.position)); } - (void)animationDidStop:(CAAnimation *)anim finished:(BOOL)flag
{
NSLog(@"核心动画执行完毕 %@", NSStringFromCGPoint(self.cutomView.layer.position));
} - (void)test
{
// 1.UIVIEW封装的动画, 动画执行完毕之后不会反弹
NSLog(@"动画执行之前: %@",NSStringFromCGPoint(self.cutomView.center));
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:2.0];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(didStopAnimatino)];
self.cutomView.center = CGPointMake(, );
[UIView commitAnimations]; } - (void)didStopAnimatino
{
NSLog(@"动画执行完毕 %@", NSStringFromCGPoint(self.cutomView.center));
} @end

IOS UIView动画(封装动画)的更多相关文章

  1. iOS UIView简单缩放动画

    @interface ViewController () { UIView *animationView; UIButton *button; CGPoint animationPoint; } @e ...

  2. iOS开发UI篇—核心动画(UIView封装动画)

    iOS开发UI篇—核心动画(UIView封装动画) 一.UIView动画(首尾) 1.简单说明 UIKit直接将动画集成到UIView类中,当内部的一些属性发生改变时,UIView将为这些改变提供动画 ...

  3. ios uiview封装动画(摘录)

    iOS开发UI篇—核心动画(UIView封装动画) 一.UIView动画(首尾) 1.简单说明 UIKit直接将动画集成到UIView类中,当内部的一些属性发生改变时,UIView将为这些改变提供动画 ...

  4. UIView封装动画--iOS利用系统提供方法来做转场动画

    UIView封装动画--iOS利用系统提供方法来做转场动画 UIViewAnimationOptions option; if (isNext) { option=UIViewAnimationOpt ...

  5. iOS:抽屉侧滑动画两种形式(1、UIView侧滑 2、ViewController侧滑)

    前言: 在iOS中抽屉动画是很常用的一种技术,使用它有很炫的体验效果,为app增添特色,形式就两种,一个是UIView的侧滑,另一个就是ViewController的侧滑. 实现方式: 抽屉侧滑动画有 ...

  6. IOS UIVIEW layer动画 总结(转)

    转发自:http://www.aichengxu.com/article/%CF%B5%CD%B3%D3%C5%BB%AF/16306_12.html   IOS UIVIEW layer动画 总结, ...

  7. 核心动画(UIView封装动画)

    一.UIView动画(首尾) 1.简单说明 UIKit直接将动画集成到UIView类中,当内部的一些属性发生改变时,UIView将为这些改变提供动画支持 执行动画所需要的工作由UIView类自动完成, ...

  8. iOS - UIView 动画

    1.UIView 动画 核心动画 和 UIView 动画 的区别: 核心动画一切都是假象,并不会真实的改变图层的属性值,如果以后做动画的时候,不需要与用户交互,通常用核心动画(转场). UIView ...

  9. 核心动画(UIView封装动画)-转

    一.UIView动画(首尾) 1.简单说明 UIKit直接将动画集成到UIView类中,当内部的一些属性发生改变时,UIView将为这些改变提供动画支持. 执行动画所需要的工作由UIView类自动完成 ...

  10. iOS UIView 动画浅谈

    UIView 等会效果简单实现,哪一个登录页面的demo来举例子吧. + (void)animateWithDuration:(NSTimeInterval)duration animations:( ...

随机推荐

  1. 与"shark"相关的表达

    The word shark can be used to describe someone who is tricky and uses other people. Shark这个单词可以用来形容一 ...

  2. sourcetree 不停的让输入密码,报 password required

    sourcetree 不停的让输入密码,报 password required sourcetree 不停的让输入密码,报 password required1.在终端(terminal)打开你的工程 ...

  3. Codeforces Round #558 (Div. 2)B(SET,模拟)

    #include<bits/stdc++.h>using namespace std;int a[100007];int cnt[100007];int main(){    int n; ...

  4. 2017-10-3 清北刷题冲刺班p.m

    a [问题描述]你是能看到第一题的 friends 呢.——hja给你一个只有小括号和中括号和大括号的括号序列,问该序列是否合法.[输入格式]一行一个括号序列.[输出格式]如果合法,输出 OK,否则输 ...

  5. mysql安装等操作

    CentOS 6.5系统中安装配置MySQL数据库 卸载掉原有mysql rpm -qa | grep mysql // 这个命令就会查看该操作系统上是否已经安装了mysql数据库 rpm -e my ...

  6. Unity---MonoBehaviour9大生命周期

    1.MonoBehaviour9大生命周期 MonoBehaviour是一个基类,所有Unity脚本都派生自该类. Awake():在脚本实例化时被调用. Start():在Awake之后,Updat ...

  7. Java Script 第二章.

    对象: JavaScript中的所有事物都是对象:字符串,数组,数值,函数..... JavaScript中提供多个内建对象,比如说 String,  Date,  Array等等.对象只是带有属性和 ...

  8. easyui-dialog对话框练习

    <div id="dl1" class="easyui-dialog" title="窗口" style="width:40 ...

  9. 分析师分析业务维度,(个人制作分析思维导图Xmind)

    个人在咨询公司做过分析师(分析师必须懂运营),该咨询公司主要针对电商,零售 结合公司的搭建的CRM系统及报表体系,列了个分析师分析维度,搭建公司自己的BI系统 个人经验:分析师的分析思维可以多看看艾瑞 ...

  10. postgresql备份数据库

    备份数据库:pg_dump -U username -h localhost -f /me.sql 数据库名; 恢复数据库:psql -U username -h localhost -f /me.s ...