http://blog.csdn.net/u013741809/article/details/38511741

5 Steps For Using Facebook Pop

 
  // 1. Pick a Kind Of Animation 选择一种动画方式  //  POPBasicAnimation  POPSpringAnimation POPDecayAnimation
POPSpringAnimation *basicAnimation = [POPSpringAnimation animation]; // 2. Decide weather you will animate a view property or layer property, Lets pick a View Property and pick kPOPViewFrame 决定你要用视图属性或者是层的属性,此处选择了一个视图属性并且选择了 kPOPViewFrame这个属性
// View Properties (视图属性的罗列)- kPOPViewAlpha kPOPViewBackgroundColor kPOPViewBounds kPOPViewCenter kPOPViewFrame kPOPViewScaleXY kPOPViewSize
// Layer Properties (层属性的罗列)- kPOPLayerBackgroundColor kPOPLayerBounds kPOPLayerScaleXY kPOPLayerSize kPOPLayerOpacity kPOPLayerPosition kPOPLayerPositionX kPOPLayerPositionY kPOPLayerRotation kPOPLayerBackgroundColor
basicAnimation.property = [POPAnimatableProperty propertyWithName:kPOPViewFrame]; // 3. Figure Out which of 3 ways to set toValue 三种设置toValue的方法
// anim.toValue = @(1.0);
// anim.toValue = [NSValue valueWithCGRect:CGRectMake(0, 0, 400, 400)];
// anim.toValue = [NSValue valueWithCGSize:CGSizeMake(40, 40)];
basicAnimation.toValue=[NSValue valueWithCGRect:CGRectMake(0, 0, 90, 190)]; // 4. Create Name For Animation & Set Delegate为动画起个名字,并设置代理
basicAnimation.name=@"AnyAnimationNameYouWant";
basicAnimation.delegate=self // 5. Add animation to View or Layer, we picked View so self.tableView and not layer which would have been self.tableView.layer给视图或层加动画效果,我们选择了一个视图(self.tableView)来添加,而不是层(self.tableView.layer)
[self.tableView pop_addAnimation:basicAnimation forKey:@"WhatEverNameYouWant"];

Step 1 Pick Kind of Animation第一步 选择一个动画类型

POPBasicAnimation 基础动画

POPBasicAnimation *basicAnimation = [POPBasicAnimation animation];
basicAnimation.timingFunction=[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];
// kCAMediaTimingFunctionLinear kCAMediaTimingFunctionEaseIn kCAMediaTimingFunctionEaseOut kCAMediaTimingFunctionEaseInEaseOut

POPSpringAnimation 弹性动画

POPSpringAnimation *springAnimation = [POPSpringAnimation animation];
springAnimation.velocity=@(1000); // change of value units per second每秒都改变属性
springAnimation.springBounciness=14; // value between 0-20 default at 4值的范围是0~20 默认为4
springAnimation.springSpeed=3; // value between 0-20 default at 4

POPDecayAnimation 衰减动画

POPDecayAnimation *decayAnimation=[POPDecayAnimation animation];
decayAnimation.velocity=@(233); //change of value units per second
decayAnimation.deceleration=.833; //range of 0 to 1

Example

POPBasicAnimation *basicAnimation = [POPBasicAnimation animation];

Step 2 Decide if you will animate a view property or layer property第二部决定你要把动画加在视图属性还是层属性

View Properties 视图属性

Alpha - kPOPViewAlpha
Color - kPOPViewBackgroundColor
Size - kPOPViewBounds
Center - kPOPViewCenter
Location & Size - kPOPViewFrame
Size - kPOPViewScaleXY
Size(Scale) - kPOPViewSize

Layer Properties 层属性

Color - kPOPLayerBackgroundColor
Size - kPOPLayerBounds
Size - kPOPLayerScaleXY
Size - kPOPLayerSize
Opacity - kPOPLayerOpacity
Position - kPOPLayerPosition
X Position - kPOPLayerPositionX
Y Position - kPOPLayerPositionY
Rotation - kPOPLayerRotation
Color - kPOPLayerBackgroundColor

Example

POPBasicAnimation *basicAnimation = [POPBasicAnimation animation];

Note: Works on any Layer property or any object that inherits from UIView such as UIToolbar | UIPickerView | UIDatePicker | UIScrollView | UITextView | UIImageView | UITableViewCell | UIStepper | UIProgressView | UIActivityIndicatorView | UISwitch | UISlider | UITextField | UISegmentedControl | UIButton | UIView | UITableView

对所有的层或者是任何继承UIView的子类像UIToolbar巴拉巴拉...

Step 3 Find your property below then add and set .toValue找到你要操作的属性添加并设置数值

View Properties

Alpha - kPOPViewAlpha
POPBasicAnimation *basicAnimation = [POPBasicAnimation animation];
basicAnimation.property = [POPAnimatableProperty propertyWithName:kPOPViewAlpha];
basicAnimation.toValue= @(0); // scale from 0 to 1 缩放的范围0~1
Color - kPOPViewBackgroundColor
POPSpringAnimation *basicAnimation = [POPSpringAnimation animation];
basicAnimation.property = [POPAnimatableProperty propertyWithName: kPOPLayerBackgroundColor];
basicAnimation.toValue= [UIColor redColor];
Size - kPOPViewBounds
POPBasicAnimation *basicAnimation = [POPBasicAnimation animation];
basicAnimation.property = [POPAnimatableProperty propertyWithName:kPOPViewBounds];
basicAnimation.toValue=[NSValue valueWithCGRect:CGRectMake(0, 0, 90, 190)]; //first 2 values dont matter
Center - kPOPViewCenter
POPBasicAnimation *basicAnimation = [POPBasicAnimation animation];
basicAnimation.property = [POPAnimatableProperty propertyWithName:kPOPViewCenter];
basicAnimation.toValue=[NSValue valueWithCGPoint:CGPointMake(200, 200)];
Location & Size - kPOPViewFrame
POPBasicAnimation *basicAnimation = [POPBasicAnimation animation];
basicAnimation.property = [POPAnimatableProperty propertyWithName:kPOPViewFrame];
basicAnimation.toValue=[NSValue valueWithCGRect:CGRectMake(140, 140, 140, 140)];
Size - kPOPViewScaleXY
POPBasicAnimation *basicAnimation = [POPBasicAnimation animation];
basicAnimation.property = [POPAnimatableProperty propertyWithName:kPOPViewScaleXY];
basicAnimation.toValue=[NSValue valueWithCGSize:CGSizeMake(3, 2)];
Size(Scale) - kPOPViewSize
POPBasicAnimation *basicAnimation = [POPBasicAnimation animation];
basicAnimation.property = [POPAnimatableProperty propertyWithName:kPOPViewSize];
basicAnimation.toValue=[NSValue valueWithCGSize:CGSizeMake(30, 200)];

Layer Properties

Color - kPOPLayerBackgroundColor
POPSpringAnimation *basicAnimation = [POPSpringAnimation animation];
basicAnimation.property = [POPAnimatableProperty propertyWithName: kPOPLayerBackgroundColor];
basicAnimation.toValue= [UIColor redColor];
Size - kPOPLayerBounds
POPSpringAnimation *basicAnimation = [POPSpringAnimation animation];
basicAnimation.property = [POPAnimatableProperty propertyWithName: kPOPLayerBounds];
basicAnimation.toValue= [NSValue valueWithCGRect:CGRectMake(0, 0, 90, 90)]; //first 2 values dont matter
Size - kPOPLayerScaleXY
POPBasicAnimation *basicAnimation = [POPBasicAnimation animation];
basicAnimation.property = [POPAnimatableProperty propertyWithName: kPOPLayerScaleXY];
basicAnimation.toValue= [NSValue valueWithCGSize:CGSizeMake(2, 1)];//increases width and height scales
Size - kPOPLayerSize
POPBasicAnimation *basicAnimation = [POPBasicAnimation animation];
basicAnimation.property = [POPAnimatableProperty propertyWithName:kPOPLayerSize];
basicAnimation.toValue= [NSValue valueWithCGSize:CGSizeMake(200, 200)];
Opacity - kPOPLayerOpacity
POPSpringAnimation *basicAnimation = [POPSpringAnimation animation];
basicAnimation.property = [POPAnimatableProperty propertyWithName: kPOPLayerOpacity];
basicAnimation.toValue = @(0);
Position - kPOPLayerPosition
POPSpringAnimation *basicAnimation = [POPSpringAnimation animation];
basicAnimation.property = [POPAnimatableProperty propertyWithName: kPOPLayerPosition];
basicAnimation.toValue= [NSValue valueWithCGRect:CGRectMake(130, 130, 0, 0)];//last 2 values dont matter
X Position - kPOPLayerPositionX
POPSpringAnimation *basicAnimation = [POPSpringAnimation animation];
basicAnimation.property = [POPAnimatableProperty propertyWithName: kPOPLayerPositionX];
basicAnimation.toValue= @(240);
Y Position - kPOPLayerPositionY
POPSpringAnimation *anim = [POPSpringAnimation animation];
anim.property=[POPAnimatableProperty propertyWithName:kPOPLayerPositionY];
anim.toValue = @(320);
Rotation - kPOPLayerRotation
POPSpringAnimation *basicAnimation = [POPSpringAnimation animation];
basicAnimation.property = [POPAnimatableProperty propertyWithName: kPOPLayerRotation];
basicAnimation.toValue= @(M_PI/4); //2 M_PI is an entire rotation

Note: Property Changes work for all 3 animation types - POPBasicAnimation POPSpringAnimation POPDecayAnimation改变属性对所有三种动画方式都适用

Example

POPSpringAnimation *basicAnimation = [POPSpringAnimation animation];
basicAnimation.property = [POPAnimatableProperty propertyWithName: kPOPLayerRotation];
basicAnimation.toValue= @(M_PI/4); //2 M_PI is an entire rotation

Step 4 Create Name & Delegate For Animation第四步为动画创建名字和代理

basicAnimation.name=@"WhatEverAnimationNameYouWant";
basicAnimation.delegate=self;
Declare Delegate Protocol <POPAnimatorDelegate>声明代理协议

Delegate Methods 代理方法

 <POPAnimatorDelegate> 

- (void)animatorWillAnimate:(POPAnimator *)animator;将要执行动画的方法
- (void)animatorDidAnimate:(POPAnimator *)animator;执行完动画的方法

Example

POPSpringAnimation *basicAnimation = [POPSpringAnimation animation];
basicAnimation.property = [POPAnimatableProperty propertyWithName:kPOPViewFrame];
basicAnimation.toValue=[NSValue valueWithCGRect:CGRectMake(0, 0, 90, 190)];
basicAnimation.name=@"WhatEverAnimationNameYouWant";
basicAnimation.delegate=self;

Step 5 Add animation to View 给view添加动画

 [self.tableView pop_addAnimation:basicAnimation forKey:@"WhatEverNameYouWant"];

Example

  POPSpringAnimation *basicAnimation = [POPSpringAnimation animation];
basicAnimation.property = [POPAnimatableProperty propertyWithName:kPOPViewFrame];
basicAnimation.toValue=[NSValue valueWithCGRect:CGRectMake(0, 0, 90, 190)];
basicAnimation.name=@"hiiidd";
basicAnimation.delegate=self;
[self.tableView pop_addAnimation:basicAnimation forKey:@"WhatEverNameYouWant"];
也不算是翻译,就是贴一个官方的例子,理解起来容易一点.如有不对之处,请指出,及时改正.

转 脸书pop动画的五个步骤的更多相关文章

  1. iOS动画——弹窗动画(pop动画)

    用pop动画简单实现弹窗的缩放和渐变,感觉这个动画常用,就写一下博客 pop动画是Facebook推出的动画引擎,请自行到GitHub上搜索下载拖拽导入xcode项目中. 更多pop动画使用和原理可网 ...

  2. 用POP动画引擎实现衰减动画(POPDecayAnimation)

    效果图: #import "ViewController.h" #import <POP.h> @interface ViewController () @end @i ...

  3. POP动画引擎中Layer与CALayer的一点区别

    POP动画引擎是facebook提供的一个开源框架, 可以实现很多的动画效果, 这里就不一一介绍啦, 有兴趣的童鞋请移步: https://github.com/facebook/pop 下面简单的讲 ...

  4. 用POP动画编写带富文本的自定义动画效果

    用POP动画编写带富文本的自定义动画效果 [源码] https://github.com/YouXianMing/UI-Component-Collection [效果] [特点] * 支持富文本 * ...

  5. POP动画[1]

    POP动画[1] pop动画是facebook扩展CoreAnimation的,使用及其方便:) 1:Spring系列的弹簧效果(两个动画kPOPLayerBounds与kPOPLayerCorner ...

  6. 用POP动画模拟真实秒钟摆动效果

    用POP动画模拟真实秒钟摆动效果 静态图: 动画图: 此处用到了POP中的Spring系列动画,现提供源码如下: SecondClockView.h 与 SecondClockView.m // // ...

  7. POP动画[3]

    POP动画[3] 这一节主要讲解POP动画的自定义动画属性. POP动画中有一个参数,叫timingFunction,与CoreAnimation中的一个参数CAMediaTimingFunction ...

  8. POP动画[2]

    POP动画[2] 1:定制控制器间的转场动画. 源码有点多-_-!! // // RootViewController.h // Animation // // Copyright (c) 2014年 ...

  9. 自定义UINavigationController push和pop动画

    http://segmentfault.com/q/1010000000143983 默认的UINavigationController push和pop的默认动画都是左右滑动推出,我的应用要求这种界 ...

随机推荐

  1. iOS 构造方法

    构造方法:用于在对象创建出来的时候为对象的成员变量或者属性赋值 1.构造方法就是初始化对象的方法,它属于对象方法.构造方法分为系统自带和自定义构造方法. 如何创建自定义构造方法: 属于对象方法那么以  ...

  2. 在windows下装2个mysql数据库的办法

    如下 记录下以免找不到 http://blog.chinaunix.net/uid-77311-id-3450734.html 然后接下来是 1045的解决方案 可以在随便中找

  3. 如何设置虚拟机、开发板、windows IP才能互相PING通

    1.虚拟机选择桥接模式,并且在编辑菜单网络参数中,选择已桥接到Relteck-(表本地有限网卡) 2.设置Linux IP地址 192.168.1.10 3.设置Windows本地连接IP地址192. ...

  4. ASP.NET MVC概述

    原文:http://www.asp.net/mvc/tutorials/older-versions/overview/asp-net-mvc-overview 这篇文章帮助你了解关于ASP.NET ...

  5. android xml产生和解析

    public static void writeToXml(Map<String, Object> map,Writer writer) throws Exception, Illegal ...

  6. 怎样用sourceTree将自己本地的项目上传到github网站上

    前言:GitHub 是基于 Git 的一个代码托管网站.开发者可以将代码在 GitHub 上开源,可以浏览其它项目的代码. 准备工作:1.github网站账号.2.sourceTree软件. 一.在g ...

  7. 【python】坑,坑,折腾一个下午python 3.5中 ImportError: No module named BeautifulSoup

    将语句 from bs4 import BeautifulSoup4 改成 from bs4 import BeautifulSoup 通过 尼玛------------------------! 总 ...

  8. Oracle wrap 测试的一些细节问题

    今天在做 wrap 的测试实验的时候,出现一个很奇怪的现象,就是加密不成功.具体表现为:1.加密后的文件大小为0kb. 2.加密后的文件仍然可视. 具体测试步骤如下: D:\Just4work\som ...

  9. 不相交集合ADT

    不相交集合数据结构保持一组不相交的动态集合S={S1,S2,...,SK},每个集合通过一个代表来识别,代表即集合中的某个成员. 如果x表示一个对象,不相交集合支持以下操作: MAKE-SET(x): ...

  10. Dev-C++之开启装逼效果

    Dev-C++是个不错的C++IDE——在10年前,它是很不错,在现在,它是个以界面丑陋和调试像吃粑粑这两点著称,如下图.