Simple use of Facebook POP Animation

Source: Internet
Author: User

Simple use of Facebook POP Animation

Simple and practical POP Animation

It is better to find that the POP state is retained after the animation ends, and the block callback is used. You can use POPAnimatableProperty to quickly add basic animations or customize property animations.


Elastic Animation

-(Void) spring {

POPSpringAnimation * framePOP = [POPSpringAnimationanimationWithPropertyNamed: kPOPViewBackgroundColor];

FramePOP. springSpeed = 10.f;

FramePOP. springBounciness = 4.f;

FramePOP. toValue = [UIColorgreenColor];

[FramePOPsetCompletionBlock: ^ (POPAnimation * anim, BOOL finsih ){

If (finsih ){

NSLog (@ "view. frame = % @", NSStringFromCGRect (view. frame ));

}

}];

[Viewpop_addAnimation: framePOP forKey: @ "go"];

}


Animation slowdown

-(Void) Decay {

POPDecayAnimation * decay = [POPDecayAnimationanimationWithPropertyNamed: kPOPViewFrame];

// Decay. toValue = [NSValue valueWithCGRect: CGRectMake (200,400,100,100)];

Decay. velocity = [NSValuevalueWithCGRect: CGRectMake (200,300,100,100)];

[Viewpop_addAnimation: decay forKey: @ "go"];

}



Basic Animation

-(Void) basic {

POPBasicAnimation * basicAnimation = [POPBasicAnimationanimationWithPropertyNamed: kPOPLayerCornerRadius];

BasicAnimation. toValue = [NSNumbernumberWithFloat: CGRectGetHeight (view. frame)/2.];

BasicAnimation. timingFunction = [CAMediaTimingFunctionfunctionWithName: kCAMediaTimingFunctionEaseInEaseOut];

// BasicAnimation. duration = 3.f;

[BasicAnimationsetCompletionBlock: ^ (POPAnimation * ani, BOOL fin ){

If (fin ){

NSLog (@ "view. frame = % @", NSStringFromCGRect (view. frame ));

// POPBasicAnimation * newBasic = [POPBasicAnimation easeInEaseOutAnimation];

// NewBasic. property = [POPAnimatableProperty propertyWithName: kPOPLayerCornerRadius];

// NewBasic. toValue = [NSNumber numberWithFloat: 0];

// [View. layer pop_addAnimation: newBasic forKey: @ "go"];

}

}];

[View. layerpop_addAnimation: basicAnimation forKey: @ "frameChange"];


}


Composite Animation

-(Void) group

{

View. transform = CGAffineTransformMakeRotation (M_PI_2/3 );

POPBasicAnimation * spring = [POPBasicAnimationanimationWithPropertyNamed: kPOPLayerPositionY];

Spring. beginTime = CACurrentMediaTime ();

Spring. duration =. 4f;

Spring. fromValue = [NSNumbernumberWithFloat:-100.f];

Spring. toValue = [NSNumbernumberWithFloat: CGRectGetMinY (view. frame) + 80];

[SpringsetCompletionBlock: ^ (POPAnimation * ani, BOOL fin ){

}];

POPBasicAnimation * basic = [POPBasicAnimationanimationWithPropertyNamed: kPOPLayerRotation];

Basic. beginTime = CACurrentMediaTime ();

Basic. timingFunction = [CAMediaTimingFunctionfunctionWithName: kCAMediaTimingFunctionEaseInEaseOut];

Basic. toValue = [NSNumbernumberWithFloat:-M_PI_4];

Basic. duration =. 4f;

POPBasicAnimation * rotation = [POPBasicAnimationanimationWithPropertyNamed: kPOPLayerRotation];

Rotation. beginTime = CACurrentMediaTime () +. 4f;

Rotation. toValue = [NSNumbernumberWithFloat: 0.f];

Rotation. timingFunction = [CAMediaTimingFunctionfunctionWithName: kCAMediaTimingFunctionEaseInEaseOut];

Rotation. duration =. 25f;

POPBasicAnimation * donw = [POPBasicAnimationanimationWithPropertyNamed: kPOPLayerPositionY];

Donw. beginTime = CACurrentMediaTime () + 0.4f;

Donw. toValue = [NSNumbernumberWithFloat: CGRectGetMinY (view. frame)];

Donw. duration =. 25f;

Donw. timingFunction = [CAMediaTimingFunctionfunctionWithName: kCAMediaTimingFunctionEaseInEaseOut];

[View. layerpop_addAnimation: spring forKey: @ "spring"];

[View. layerpop_addAnimation: basic forKey: @ "basic"];

[View. layerpop_addAnimation: donw forKey: @ "down"];

[View. layerpop_addAnimation: rotation forKey: @ "rotation"];

}





Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.