iOS Animation各种动画效果

来源:互联网 发布:美工设计职责 编辑:程序博客网 时间:2024/06/07 11:24

//图片进度显示效果,什么时间点显示到什么程度

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];





0 0
原创粉丝点击