放大缩小动画
2015-04-17 10:22
288 查看
1.
makeImageCard = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"makeCard_Image.png"]];
makeImageCard.frame = CGRectMake(([[UIScreen mainScreen] bounds].size.width-543/1.9)/2, self.navigationController.navigationBar.frame.size.height+[[UIApplication sharedApplication] statusBarFrame].size.height, 543/1.9, 998/2.36);
makeImageCard.userInteractionEnabled = YES;
[self.view addSubview:makeImageCard];
CAKeyframeAnimation* animation = [CAKeyframeAnimation animationWithKeyPath:@"transform"];
animation.duration = 0.5;
NSMutableArray *values = [NSMutableArray array];
[values addObject:[NSValue valueWithCATransform3D:CATransform3DMakeScale(0.9, 0.9, 1.0)]];
[values addObject:[NSValue valueWithCATransform3D:CATransform3DMakeScale(1.1, 1.1, 1.0)]];
[values addObject:[NSValue valueWithCATransform3D:CATransform3DMakeScale(0.9, 0.9, 1.0)]];
[values addObject:[NSValue valueWithCATransform3D:CATransform3DMakeScale(1.0, 1.0, 1.0)]];
animation.values = values;
[makeImageCard.layer addAnimation:animation forKey:nil];
2.
#pragma mark - Showing popup
- (void)showInView:(UIView *)parentView
centerAtPoint:(CGPoint)pos
duration:(CGFloat)waitDuration
completion:(void (^)(void))block
{
self.center = pos;
self.animationCompletion = block;
CABasicAnimation *forwardAnimation = [CABasicAnimation animationWithKeyPath:@"transform.scale"];
forwardAnimation.duration = self.forwardAnimationDuration;
forwardAnimation.timingFunction = [CAMediaTimingFunction functionWithControlPoints:0.5f :1.7f :0.6f :0.85f];
forwardAnimation.fromValue = [NSNumber numberWithFloat:0.0f];
forwardAnimation.toValue = [NSNumber numberWithFloat:1.0f];
CABasicAnimation *reverseAnimation = [CABasicAnimation animationWithKeyPath:@"transform.scale"];
reverseAnimation.duration = self.backwardAnimationDuration;
reverseAnimation.beginTime = forwardAnimation.duration + waitDuration;
reverseAnimation.timingFunction = [CAMediaTimingFunction functionWithControlPoints:0.4f :0.15f :0.5f :-0.7f];
reverseAnimation.fromValue = [NSNumber numberWithFloat:1.0f];
reverseAnimation.toValue = [NSNumber numberWithFloat:0.0f];
CAAnimationGroup *animationGroup = [CAAnimationGroup animation];
animationGroup.animations = [NSArray arrayWithObjects:forwardAnimation, reverseAnimation, nil];
animationGroup.delegate = self;
animationGroup.duration = forwardAnimation.duration + reverseAnimation.duration + waitDuration;
animationGroup.removedOnCompletion = NO;
animationGroup.fillMode = kCAFillModeForwards;
[parentView addSubview:self];
[UIView animateWithDuration:animationGroup.duration
delay:0.0
options:0
animations:^{
[self.layer addAnimation:animationGroup
forKey:@"kLPAnimationKeyPopup"];
}
completion:^(BOOL finished) {
}];
}
3
CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"transform.scale"];
animation.toValue = [NSValue valueWithCATransform3D:CATransform3DMakeScale(1.05, 1.05, 1)];;
animation.duration = 0.07;
animation.autoreverses = YES;
animation.repeatCount = 1;
animation.removedOnCompletion = YES;
animation.fillMode = kCAFillModeForwards;
[deletedAlert.layer addAnimation:animation forKey:nil];
deletedAlert.transform = CGAffineTransformMakeScale(1.0, 1.0);
makeImageCard = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"makeCard_Image.png"]];
makeImageCard.frame = CGRectMake(([[UIScreen mainScreen] bounds].size.width-543/1.9)/2, self.navigationController.navigationBar.frame.size.height+[[UIApplication sharedApplication] statusBarFrame].size.height, 543/1.9, 998/2.36);
makeImageCard.userInteractionEnabled = YES;
[self.view addSubview:makeImageCard];
CAKeyframeAnimation* animation = [CAKeyframeAnimation animationWithKeyPath:@"transform"];
animation.duration = 0.5;
NSMutableArray *values = [NSMutableArray array];
[values addObject:[NSValue valueWithCATransform3D:CATransform3DMakeScale(0.9, 0.9, 1.0)]];
[values addObject:[NSValue valueWithCATransform3D:CATransform3DMakeScale(1.1, 1.1, 1.0)]];
[values addObject:[NSValue valueWithCATransform3D:CATransform3DMakeScale(0.9, 0.9, 1.0)]];
[values addObject:[NSValue valueWithCATransform3D:CATransform3DMakeScale(1.0, 1.0, 1.0)]];
animation.values = values;
[makeImageCard.layer addAnimation:animation forKey:nil];
2.
#pragma mark - Showing popup
- (void)showInView:(UIView *)parentView
centerAtPoint:(CGPoint)pos
duration:(CGFloat)waitDuration
completion:(void (^)(void))block
{
self.center = pos;
self.animationCompletion = block;
CABasicAnimation *forwardAnimation = [CABasicAnimation animationWithKeyPath:@"transform.scale"];
forwardAnimation.duration = self.forwardAnimationDuration;
forwardAnimation.timingFunction = [CAMediaTimingFunction functionWithControlPoints:0.5f :1.7f :0.6f :0.85f];
forwardAnimation.fromValue = [NSNumber numberWithFloat:0.0f];
forwardAnimation.toValue = [NSNumber numberWithFloat:1.0f];
CABasicAnimation *reverseAnimation = [CABasicAnimation animationWithKeyPath:@"transform.scale"];
reverseAnimation.duration = self.backwardAnimationDuration;
reverseAnimation.beginTime = forwardAnimation.duration + waitDuration;
reverseAnimation.timingFunction = [CAMediaTimingFunction functionWithControlPoints:0.4f :0.15f :0.5f :-0.7f];
reverseAnimation.fromValue = [NSNumber numberWithFloat:1.0f];
reverseAnimation.toValue = [NSNumber numberWithFloat:0.0f];
CAAnimationGroup *animationGroup = [CAAnimationGroup animation];
animationGroup.animations = [NSArray arrayWithObjects:forwardAnimation, reverseAnimation, nil];
animationGroup.delegate = self;
animationGroup.duration = forwardAnimation.duration + reverseAnimation.duration + waitDuration;
animationGroup.removedOnCompletion = NO;
animationGroup.fillMode = kCAFillModeForwards;
[parentView addSubview:self];
[UIView animateWithDuration:animationGroup.duration
delay:0.0
options:0
animations:^{
[self.layer addAnimation:animationGroup
forKey:@"kLPAnimationKeyPopup"];
}
completion:^(BOOL finished) {
}];
}
3
CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"transform.scale"];
animation.toValue = [NSValue valueWithCATransform3D:CATransform3DMakeScale(1.05, 1.05, 1)];;
animation.duration = 0.07;
animation.autoreverses = YES;
animation.repeatCount = 1;
animation.removedOnCompletion = YES;
animation.fillMode = kCAFillModeForwards;
[deletedAlert.layer addAnimation:animation forKey:nil];
deletedAlert.transform = CGAffineTransformMakeScale(1.0, 1.0);
相关文章推荐
- Android通过动画实现图片重复放大和缩小
- keyframes 放大缩小动画
- js 图片放大缩小(动画效果)
- Activity 切换动画(小米图库列表进入详情页,图片从固定位置放大进入,缩小退出)
- 小程序动画-循环放大缩小的动画(一闪一闪的)
- iOS中给自定义tabBar的按钮添加点击放大缩小的动画效果
- swift3.0 图片放大缩小动画效果
- 等待进度条---三个圆点一排间隔放大缩小动画
- 给自定义tabBar的按钮添加点击放大缩小的动画
- CSS+jQuery实现的一个放大缩小动画效果
- 属性动画图片从上移动到屏幕中间,放大图片的二倍再缩小到原来,自定义圆实现倒计时,解析数据显示,点击条目实现js交互
- Android通过动画实现图片重复放大和缩小
- view 放大缩小动画效果
- 写了一个实用的图像放大缩小程序,但是动画GIF转换后不会显示了,只有第一帧
- uiviewcontroller 转场放大缩小动画
- swift3.0实现图片放大缩小动画效果
- 原创:android模仿iphone 腾讯爱看文章列表放大缩小 带动画
- 一个CSS+jQuery实现的放大缩小动画效果
- 两张图片的交换,以及放大缩小的动画
- 放大缩小容器:仿动画