POP: 一個(gè)流行的可擴(kuò)展的動(dòng)畫(huà)引擎iOS,它支持spring和衰變動(dòng)態(tài)動(dòng)畫(huà),使其可用于構(gòu)建現(xiàn)實(shí),基于物理交互衅檀。Objective - C API允許快速集成, 對(duì)于所有的動(dòng)畫(huà)和過(guò)渡他是成熟的.
1.1 POP 使用 Objective-C++ 編寫(xiě),Objective-C++ 是對(duì) C++ 的擴(kuò)展小渊,就像 Objective-C 是 C 的擴(kuò)展业扒。而至于為什么他們用 Objective-C++ 而不是純粹的 Objective-C. 可能是偏愛(ài)兢交。-.O
1.2 POP 目前由四部分組成:1. Animations漠畜;2. Engine秀睛;3. Utility尔当;4. WebCore。
舉個(gè)栗子哈哈
#import
E1:
-(void)clickPopAction
{
// kPOPLayerPositionY 向下
// kPOPLayerPositionX 向右
POPSpringAnimation*anim=[POPSpringAnimationanimationWithPropertyNamed:kPOPLayerPositionY];
// 移動(dòng)距離
anim.toValue=[[NSNumberalloc]initWithFloat:_btnPop.center.y+200];
// 從當(dāng)前 + 1s后開(kāi)始
anim.beginTime=CACurrentMediaTime()+1.0f;
// 彈力--晃動(dòng)的幅度 (springSpeed速度)
anim.springBounciness=15.0f;
[_btnPoppop_addAnimation:animforKey:@"position"];
POPSpringAnimation*anim1=[POPSpringAnimationanimationWithPropertyNamed:kPOPLayerBounds];
anim1.toValue=[NSValuevalueWithCGRect:CGRectMake(100,100,99,99)];
[_btnPoppop_addAnimation:anim1forKey:@"size"];
}
E2:在很多金融類(lèi)app中比較常見(jiàn)蹂安、支付寶中的余額包椭迎、京東金融余額、就類(lèi)似這樣
// 初始化
POPBasicAnimation*anim=[POPBasicAnimationanimation];
// 限時(shí) 1s
anim.duration=3.0;
POPAnimatableProperty*prop=[POPAnimatablePropertypropertyWithName:@"count++"initializer:^(POPMutableAnimatableProperty*prop){
prop.readBlock= ^(idobj,CGFloatvalues[]){values[0]=[[objdescription]floatValue];};
prop.writeBlock= ^(idobj,constCGFloatvalues[])
{
[objsetText:[NSStringstringWithFormat:@"%.2f",values[0]]];
};
prop.threshold=0.01;
}];
anim.property=prop;
anim.fromValue=@(0.0);
anim.toValue=@(1314.52);
[self.xt_countLabelpop_addAnimation:animforKey:@"counting"];
E3
CALayer*layer0=[CALayerlayer];
layer0.opacity=1.0;
layer0.transform=CATransform3DIdentity;
[layer0setMasksToBounds:YES];
[layer0setBackgroundColor:[UIColorcolorWithRed:0.5448green:0.6836blue:0.9986alpha:1.0].CGColor];
[layer0setCornerRadius:12.5];
[layer0setBounds:CGRectMake(0,0,25,25)];
[self.view.layeraddSublayer:layer0];
layer0.position=CGPointMake(self.view.center.x,266);
[selfperformAnimation:layer0];
-(void)performAnimation:(CALayer*)layer
{
[layerpop_removeAllAnimations];
POPBasicAnimation*anim=[POPBasicAnimationanimationWithPropertyNamed:kPOPLayerScaleXY];
staticBOOLani=YES;
if(ani){
anim.toValue=[NSValuevalueWithCGPoint:CGPointMake(1.0,1.0)];
}else{
anim.toValue=[NSValuevalueWithCGPoint:CGPointMake(1.5,1.5)];
}
ani= !ani;
anim.completionBlock= ^(POPAnimation*anim,BOOLfinished){
if(finished){[selfperformAnimation:layer];}
};
[layerpop_addAnimation:animforKey:@"Animation"];
}