1 ->
[viewContent.layer addAnimation:[self getShakeAnimation] forKey:@"transform.scale"];
- (CAAnimation*)getShakeAnimation {
CAKeyframeAnimation *animation = [CAKeyframeAnimation animation];
animation.values = [NSArray arrayWithObjects:
[NSValue valueWithCATransform3D:CATransform3DMakeRotation(M_PI_2, 0.0f, 1.0f, 0.0f)],
[NSValue valueWithCATransform3D:CATransform3DMakeRotation(M_PI, 0.0f, 0.0f, 0.0f)],
[NSValue valueWithCATransform3D:CATransform3DMakeRotation(M_PI * 2, 0.0f, 1.0f, 0.0f)],nil];
animation.duration = 0.8f;
animation.delegate = self;
return animation;
}
2 -> animate view from bottom to top
-(void)makeAnimation
{
CGRect optionsFrame = {0,480,320,480};
userNameEmailView.frame = optionsFrame;
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1];
[self.view addSubview:userNameEmailView];
//optionsFrame.origin.x -= optionsFrame.size.width;
optionsFrame.origin.y -= optionsFrame.size.height;
userNameEmailView.frame = optionsFrame;
[UIView commitAnimations];
}
Slow speed of keyBoard hiding
[UIView animateWithDuration:1 delay:0 options:UIViewAnimationOptionBeginFromCurrentState animations:^{
[self.view endEditing:YES];
}completion:nil];
3 -> Shake the view like error is generating
-(void)shakeTheView
{
CABasicAnimation *shake = [CABasicAnimation animationWithKeyPath:@"position"];
[shake setDuration:0.1];
[shake setRepeatCount:2];
[shake setAutoreverses:YES];
[shake setFromValue:[NSValue valueWithCGPoint:
CGPointMake(searchByCountryView.center.x - 15,searchByCountryView.center.y)]];
[shake setToValue:[NSValue valueWithCGPoint:
CGPointMake(searchByCountryView.center.x + 15, searchByCountryView.center.y)]];
[searchByCountryView.layer addAnimation:shake forKey:@"position"];
}
4 . -> Spin your view,best for loading type image
- (void)spinTheView
{
[CATransaction begin];
[CATransaction setValue:(id)kCFBooleanTrue forKey:kCATransactionDisableActions];
CGRect frame = [searchByCountryView frame];
searchByCountryView.layer.anchorPoint = CGPointMake(0.5, 0.5);
searchByCountryView.layer.position = CGPointMake(frame.origin.x + 0.5 * frame.size.width, frame.origin.y + 0.5 * frame.size.height);
[CATransaction commit];
[CATransaction begin];
[CATransaction setValue:(id)kCFBooleanFalse forKey:kCATransactionDisableActions];
[CATransaction setValue:[NSNumber numberWithFloat:2.0] forKey:kCATransactionAnimationDuration];
CABasicAnimation *animation;
animation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
animation.fromValue = [NSNumber numberWithFloat:0.0];
animation.toValue = [NSNumber numberWithFloat:2 * M_PI];
animation.timingFunction = [CAMediaTimingFunction functionWithName: kCAMediaTimingFunctionLinear];
animation.delegate = self;
[searchByCountryView.layer addAnimation:animation forKey:@"rotationAnimation"];
[CATransaction commit];
}
Way2 to spin ->
[self runSpinAnimationOnView:self.football duration:3.0 rotations:1 repeat:1000000];
- (void) runSpinAnimationOnView:(UIView*)view duration:(CGFloat)duration rotations:(CGFloat)rotations repeat:(CGFloat)repeat
{
CABasicAnimation* rotationAnimation;
rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
rotationAnimation.toValue = [NSNumber numberWithFloat: M_PI * 2.0 /* full rotation*/ * rotations * duration ];
rotationAnimation.duration = duration;
rotationAnimation.cumulative = YES;
rotationAnimation.repeatCount = repeat;
[view.layer addAnimation:rotationAnimation forKey:@"rotationAnimation"];
}
3 -> Load the view From left side
CATransition *animation = [CATransition animation];
[[self navigationController] pushViewController:elementController animated:NO];
[animation setDuration:0.45];
[animation setType:kCATransitionPush];
[animation setSubtype:kCATransitionFromLeft];
[animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionDefault]];
[[elementController.view layer] addAnimation:animation forKey:@"SwitchToView1"];
Animation
Comments
Post a Comment