faceBook POP

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

// 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

//  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 pop_addAnimation:basicAnimation forKey:@"WhatEverNameYouWant"];

Step 1 Pick Kind of Animation(选择一种动画类别)

1,

POPBasicAnimation     (基本)动效可以在给定时间的运动中插入数值调整运动节奏

POPBasicAnimation *basicAnimation = [POPBasicAnimation animation];

basicAnimation.timingFunction=[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];

// kCAMediaTimingFunctionLinear  kCAMediaTimingFunctionEaseIn  kCAMediaTimingFunctionEaseOut  kCAMediaTimingFunctionEaseInEaseOut

2,

POPSpringAnimation    (弹性)动效可以赋予物体愉悦的弹性效果

POPSpringAnimation *springAnimation = [POPSpringAnimation animation];

springAnimation.velocity=@(1000);      // change of value units per second

springAnimation.springBounciness=14;    // value between 0-20 default at 4

springAnimation.springSpeed=3;    // value between 0-20 default at 4

3,

POPDecayAnimation    (衰减) 动效可以用来逐渐减慢物体的速度至停止

Step 2 Decide if you will animate a view property or layer property (步骤2决定是否将动画视图属性或图层属性)


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


Step 3 Find your property below then add and set .toValue  (步骤3找到下面你的财产,然后添加和设置。价值)


View Properties (View 属性)

Alpha - kPOPViewAlpha (透明度)

POPBasicAnimation *basicAnimation = [POPBasicAnimation animation];

basicAnimation.property = [POPAnimatableProperty propertyWithName:kPOPViewAlpha];

basicAnimation.toValue= @(0); // scale from 0 to 1

Color - kPOPViewBackgroundColor(颜色)

POPSpringAnimation *basicAnimation = [POPSpringAnimation animation];

basicAnimation.property = [POPAnimatableProperty propertyWithName: kPOPViewBackgroundColor];

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(Layer 属性)(同上)

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>(别忘了代理)


三个代理方法

- (void)pop_animationDidStart:(POPAnimation *)anim;

- (void)pop_animationDidStop:(POPAnimation *)anim finished:(BOOL)finished;

- (void)pop_animationDidReachToValue:(POPAnimation *)aim;

例子:

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.yourview pop_addAnimation:basicAnimation forKey:@"WhatEverNameYouWant"];


完整的例子:

⬇️⬇️⬇️⬇️⬇️⬇️⬇️⬇️⬇️⬇️⬇️⬇️⬇️⬇️⬇️⬇️⬇️⬇️⬇️⬇️⬇️⬇️

POPSpringAnimation *basicAnimation = [POPSpringAnimation animation];

basicAnimation.property = [POPAnimatableProperty propertyWithName:kPOPViewFrame];

basicAnimation.toValue=[NSValue valueWithCGRect:CGRectMake(0, 0, 90, 190)];

basicAnimation.name=@"SomeAnimationNameYouChoose";

basicAnimation.delegate=self;

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

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 193,812评论 5 459
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 81,626评论 2 371
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 141,144评论 0 319
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 52,052评论 1 263
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 60,925评论 4 355
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 46,035评论 1 272
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 36,461评论 3 381
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 35,150评论 0 253
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 39,413评论 1 290
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 34,501评论 2 307
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 36,277评论 1 325
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 32,159评论 3 312
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 37,528评论 3 298
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 28,868评论 0 17
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 30,143评论 1 250
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 41,407评论 2 341
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 40,615评论 2 335

推荐阅读更多精彩内容

  • 当听闻Facebook要开源自己的Animation框架的时候,我还以为是基于Core Animation进行的封...
    韩七夏阅读 1,065评论 0 0
  • 原文 5 Steps For Using Facebook Pop的摘要 选择一种动画样式, POPBasicAn...
    s2mh阅读 749评论 0 0
  • POP: 一个流行的可扩展的动画引擎iOS,它支持spring和衰变动态动画,使其可用于构建现实,基于物理交互。O...
    Justin_W阅读 219评论 0 0
  • 在iOS中随处都可以看到绚丽的动画效果,实现这些动画的过程并不复杂,今天将带大家一窥ios动画全貌。在这里你可以看...
    每天刷两次牙阅读 8,418评论 6 30
  • 在iOS中随处都可以看到绚丽的动画效果,实现这些动画的过程并不复杂,今天将带大家一窥iOS动画全貌。在这里你可以看...
    F麦子阅读 5,066评论 5 13