您的位置:首页 > 移动开发 > IOS开发

iOS Animation各种动画效果

2016-06-01 14:57 399 查看
//图片进度显示效果,什么时间点显示到什么程度

CAKeyframeAnimation* animation = [CAKeyframeAnimation animationWithKeyPath:@"strokeEnd"];
animation.duration = 1;
animation.values = @[@(0), @(1),@(0.75)];
animation.keyTimes = @[@(0), @(0.6), @(1)];
animation.repeatCount = 1;
[animation setRemovedOnCompletion:NO];
animation.fillMode = kCAFillModeForwards;
[_imageView.layer addAnimation:animation forKey:nil];


//图片从无到有显示动画效果

CABasicAnimation *basicAnimation = [CABasicAnimation animationWithKeyPath:@"strokeEnd"];
basicAnimation.duration = 2;
basicAnimation.fromValue = [NSNumber numberWithInteger:0];
basicAnimation.toValue = [NSNumber numberWithInteger:1];
[layer addAnimation:basicAnimation forKey:@"strokeEnd"];
[_imageView.layer addSublayer:layer];


//图片显示的各种动画效果

CATransition *animation = [CATransition animation];
[animation setDuration:1.0];
[animation setFillMode:kCAFillModeForwards];
[animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut]];
[animation setType:@"rippleEffect"];//@"cube" @"moveIn" @"reveal" @"fade"(default) @"pageCurl" @"pageUnCurl" @"suckEffect" @"rippleEffect" @"oglFlip"
[animation setSubtype:kCATransitionFromTop];
[_imageView.layer addAnimation:animation forKey:nil];


//图片位移之惯性效果

CASpringAnimation *animation = [CASpringAnimation animationWithKeyPath:@"position.x"];
animation.damping = 5;
animation.stiffness = 100;
animation.mass = 1;
animation.initialVelocity = 0;
animation.fromValue = _imageView.layer.position.x;
animation.toValue = _imageView.layer.position.x+200;
animation.duration = 3;
[_imageView.layer addAnimation:animation forKey:nil];
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: