Skip to content

Instantly share code, notes, and snippets.

@Gaia-Murata
Created May 14, 2014 10:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Gaia-Murata/050197883653eb728039 to your computer and use it in GitHub Desktop.
Save Gaia-Murata/050197883653eb728039 to your computer and use it in GitHub Desktop.
SpringAnimation
POPBasicAnimation *anim = [POPBasicAnimation animationWithPropertyNamed:kPOPViewAlpha];
anim.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
anim.duration = 3.0f;
anim.fromValue = @(0.0);
anim.toValue = @(1.0);
[_basicSampleView pop_addAnimation:anim forKey:@"fade"];
POPAnimatableProperty *countProperty = [POPAnimatableProperty propertyWithName:@"countUp" initializer:^(POPMutableAnimatableProperty *prop){
prop.readBlock = ^(UILabel *label, CGFloat values[]) {
//どの値を利用するか
values[0] = [label.text intValue];
};
prop.writeBlock = ^(UILabel *label, const CGFloat values[]) {
//変更した値をどこに更新するか
label.text = [[NSString alloc] initWithFormat:@"%d", (int)values[0]];
};
}];
POPBasicAnimation *countAnimation = [POPBasicAnimation new];
//自作プロパティをセット
countAnimation.property = countProperty;
countAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
countAnimation.duration = 10.0f;
countAnimation.fromValue = @(100);
countAnimation.toValue = @(2000);
[_countLabel pop_addAnimation:countAnimation forKey:@"constantAnimation"];
POPDecayAnimation *animX = [POPDecayAnimation animationWithPropertyNamed:kPOPLayerPositionX];
animX.velocity = @(100.0f);
[_decaySampleView.layer pop_addAnimation:animX forKey:@"slideX"];
POPDecayAnimation *animY = [POPDecayAnimation animationWithPropertyNamed:kPOPLayerPositionY];
animY.velocity = @(100.0f);
[_decaySampleView.layer pop_addAnimation:animY forKey:@"slideY"];
_sampleView.springBounciness = 24.0f;
_sampleView.springSpeed = 5.0f;
_sampleView.spring.bounds= CGRectMake(0, 0, 200, 200);
[NSObject animate:^{
_mcAnimateSampleView.springBounciness = 24.0f;
_mcAnimateSampleView.springSpeed = 10.0f;
_mcAnimateSampleView.spring.pop_scaleXY = CGPointMake(2.f, 2.f);
} completion:^(BOOL finished) {
//ScaleAnimation実行後にX軸で回転を加える
_mcAnimateSampleView.layer.pop_duration = 4;
_mcAnimateSampleView.layer.easeInEaseOut.pop_rotationX = 60.0f;
}];
POPSpringAnimation *anim = [POPSpringAnimation animationWithPropertyNamed:kPOPLayerBounds];
anim.toValue = [NSValue valueWithCGRect:CGRectMake(0, 0, 200, 200)];
anim.springSpeed = 5.0f;
anim.springBounciness = 24.0f;
[_sampleView pop_addAnimation:anim forKey:@"size"];
POPSpringAnimation *anim = [POPSpringAnimation animationWithPropertyNamed:kPOPLayerBounds];
anim.toValue = [NSValue valueWithCGRect:CGRectMake(0, 0, 200, 200)];
anim.springSpeed = 5.0f;
anim.springBounciness = 24.0f;
[_sampleView pop_addAnimation:anim forKey:@"size"];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment