关于京东购物车动画
2015-10-26 14:55
302 查看
-(void)clickShoppingCar
{
self.bottomView.countLabel.hidden
= NO;
shoppingConunt +=
1;
self.bottomView.countLabel.text
= [NSString
stringWithFormat:@"%ld",(long)shoppingConunt];
//添加一个用于动画的imageview
UIImageView * image = [[UIImageView
alloc]
initWithImage:[UIImage
imageNamed:@"iconfont-ttpodicon-2"]];
image.frame =
CGRectMake(Screen_weight-120,
CGRectGetMinX(self.bottomView.frame),
20, 20);
[self.view
addSubview:image];
//绘制贝塞尔曲线
UIBezierPath *path=[UIBezierPath
bezierPath];
path.lineWidth =
5.0;
path.lineCapStyle =
kCGLineCapRound;
//线条拐角
path.lineJoinStyle =
kCGLineCapRound;
//终点处理
[path moveToPoint:CGPointMake(Screen_weight-30,
Screen_height-35)];
[path addQuadCurveToPoint:CGPointMake(Screen_weight-150,
Screen_height-35)
controlPoint:CGPointMake(Screen_weight-60,
Screen_height-200)];
[path
stroke];
//创建关键帧
CAKeyframeAnimation *moveAnimation=[CAKeyframeAnimation
animationWithKeyPath:@"position"];
//设置属性
moveAnimation.path=path.CGPath;
// moveAnimation.duration=2.0;
// //添加动画到layer中
// [self.imageView.layer addAnimation:moveAnimation forKey:nil];
//缩放动画
CABasicAnimation *scaleAnimation=[CABasicAnimation
animationWithKeyPath:@"transform"];
//初始状态为变形前的常量的那个状态
由于formValue属性需要id类型,所以将常量封装成对象类型
scaleAnimation.fromValue=[NSValue
valueWithCATransform3D:CATransform3DIdentity] ;
scaleAnimation.toValue=[NSValue
valueWithCATransform3D:CATransform3DMakeScale(0.5,
0.5,
1)];
//scaleAnimation.duration=2.0;
// [self.imageView.layer addAnimation:scaleAnimation forKey:nil];
//透明度动画
CABasicAnimation *alphaAnimation=[CABasicAnimation
animationWithKeyPath:@"opacity"];
alphaAnimation.fromValue=@1.0;
alphaAnimation.toValue=@0.0;
// alphaAnimation.duration=2.0;
// [self.imageView.layer addAnimation:alphaAnimation forKey:nil];
//可以创建动画组来管理所有动画
,统一设置动画时长及统一添加到某个视图的layer中
CAAnimationGroup *group=[CAAnimationGroup
animation];
group.animations=@[moveAnimation,scaleAnimation];//三种动画都可以自己加
group.duration=1.0;
[image.layer
addAnimation:group
forKey:nil];
}
{
self.bottomView.countLabel.hidden
= NO;
shoppingConunt +=
1;
self.bottomView.countLabel.text
= [NSString
stringWithFormat:@"%ld",(long)shoppingConunt];
//添加一个用于动画的imageview
UIImageView * image = [[UIImageView
alloc]
initWithImage:[UIImage
imageNamed:@"iconfont-ttpodicon-2"]];
image.frame =
CGRectMake(Screen_weight-120,
CGRectGetMinX(self.bottomView.frame),
20, 20);
[self.view
addSubview:image];
//绘制贝塞尔曲线
UIBezierPath *path=[UIBezierPath
bezierPath];
path.lineWidth =
5.0;
path.lineCapStyle =
kCGLineCapRound;
//线条拐角
path.lineJoinStyle =
kCGLineCapRound;
//终点处理
[path moveToPoint:CGPointMake(Screen_weight-30,
Screen_height-35)];
[path addQuadCurveToPoint:CGPointMake(Screen_weight-150,
Screen_height-35)
controlPoint:CGPointMake(Screen_weight-60,
Screen_height-200)];
[path
stroke];
//创建关键帧
CAKeyframeAnimation *moveAnimation=[CAKeyframeAnimation
animationWithKeyPath:@"position"];
//设置属性
moveAnimation.path=path.CGPath;
// moveAnimation.duration=2.0;
// //添加动画到layer中
// [self.imageView.layer addAnimation:moveAnimation forKey:nil];
//缩放动画
CABasicAnimation *scaleAnimation=[CABasicAnimation
animationWithKeyPath:@"transform"];
//初始状态为变形前的常量的那个状态
由于formValue属性需要id类型,所以将常量封装成对象类型
scaleAnimation.fromValue=[NSValue
valueWithCATransform3D:CATransform3DIdentity] ;
scaleAnimation.toValue=[NSValue
valueWithCATransform3D:CATransform3DMakeScale(0.5,
0.5,
1)];
//scaleAnimation.duration=2.0;
// [self.imageView.layer addAnimation:scaleAnimation forKey:nil];
//透明度动画
CABasicAnimation *alphaAnimation=[CABasicAnimation
animationWithKeyPath:@"opacity"];
alphaAnimation.fromValue=@1.0;
alphaAnimation.toValue=@0.0;
// alphaAnimation.duration=2.0;
// [self.imageView.layer addAnimation:alphaAnimation forKey:nil];
//可以创建动画组来管理所有动画
,统一设置动画时长及统一添加到某个视图的layer中
CAAnimationGroup *group=[CAAnimationGroup
animation];
group.animations=@[moveAnimation,scaleAnimation];//三种动画都可以自己加
group.duration=1.0;
[image.layer
addAnimation:group
forKey:nil];
}
相关文章推荐
- 1030. Travel Plan
- 151024 总结
- 搭建高可用mongodb集群(五)--集群搭建的三种方式
- Oracle 11gR2 RAC修改监听默认端口
- win7下AdHoc网络设置共享外网上网
- 1.8 Rotate Matrix
- http长轮询&短轮询
- Android编程中聊天页面背景图片、标题栏由于键盘引起问题的解决方法
- php多线程实现方法及用法实例详解
- js的运用
- within group
- getcwd was not declared in this scope
- iOS 缓存机制 (以SDWebImage 缓存图片为例)
- 使用Apache Bench对网站性能进行测试
- sql server 类oracle vm_contact() 函数创建
- Gulp插件汇总
- jsf2.0视频
- 一份技术简历是如何搞定BAT的面试官?
- gethibernatetemplate find条件查询方法
- 百度API—身份证查询