关于京东购物车动画

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

    

}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值