美文网首页
商品添加购物车效果

商品添加购物车效果

作者: 梁苏珍 | 来源:发表于2018-06-01 17:42 被阅读0次

    CGPoint_endPoint;

 UIButton*  butOne = [[UIButton alloc]init];

    butOne.frame=CGRectMake(100,100,50,50);

    butOne.backgroundColor = [UIColor yellowColor];

    [butOneaddTarget:self action:@selector(clickBut:) forControlEvents:UIControlEventTouchUpInside];

    [self.viewaddSubview:butOne];

    UIButton * butTwo = [[UIButton alloc]init];

    butTwo.frame = CGRectMake(100, 10+CGRectGetMaxY(butOne.frame), 50, 50);

    butTwo.backgroundColor = [UIColor yellowColor];

    [butTwoaddTarget:self action:@selector(clickBut:) forControlEvents:UIControlEventTouchUpInside];

    [self.viewaddSubview:butTwo];

//终点

    UIButton* cornerView1 = [[UIButtonalloc]init];

    cornerView1.frame = CGRectMake(self.view.frame.size.width-50, self.view.frame.size.height-60, 50, 50);

    cornerView1.backgroundColor = [UIColor redColor];

    [cornerView1addTarget:self action:@selector(clickBut:) forControlEvents:UIControlEventTouchUpInside];

    [self.viewaddSubview:cornerView1];

    _endPoint= cornerView1.center;

点击方法

-(void)clickBut:(UIButton*)but

{

    CGPointcar =but.center;

    //控点

    CGPointcontrolPoint =CGPointMake(_endPoint.x, car.y);

    //创建一个layer

    CALayer *layer = [CALayer layer];

    layer.frame=CGRectMake(0,0,40,40);

    layer.position= car;

    layer.backgroundColor = [UIColor redColor].CGColor;

    layer.cornerRadius = layer.frame.size.width/2;

    layer.masksToBounds=YES;

    [self.view.layer addSublayer:layer];

    //创建关键帧

    CAKeyframeAnimation *animation = [CAKeyframeAnimation animationWithKeyPath:@"position"];

    animation.delegate=self;

    //动画时间

    animation.duration=5;

    //当动画完成,停留到结束位置

    animation.removedOnCompletion = NO;

    animation.fillMode = kCAFillModeForwards;

    //当方法名字遇到create,new,copy,retain,都需要管理内存

    CGMutablePathRef path = CGPathCreateMutable();

    //设置起点

    CGPathMoveToPoint(path,NULL, car.x, car.y);

    CGPathAddQuadCurveToPoint(path,NULL, controlPoint.x, controlPoint.y,_endPoint.x,_endPoint.y);

    //设置动画路径

    animation.path= path;

    //执行动画

    [layeraddAnimation:animationforKey:nil];

    //释放路径

    CGPathRelease(path);

}

相关文章

  • 商品添加购物车效果

    CGPoint_endPoint; UIButton* butOne = [[UIButton alloc]i...

  • 贝塞尔曲线的应用(二)

    购物车添加商品实现轨迹动画 先看下实现效果 分析下实现原理,起始点是添加按钮,购物车是结束点,我们把控制点的x坐标...

  • Vue + Vuex 实现购物车

    功能点拆分 在商品详情页点击添加购物车按钮,对应商品将传到购物车页面 购物车页面顶部商品数量展示 购物车页面商品列...

  • 购物车模块显示下架状态的商品

    首先这是个bug用户往购物车里添加商品是通过购物车模块的添加功能,但执行添加功能之前需要有商品的productId...

  • 8.购物车管理

    购物车管理模块是属于用户侧模块,主要有7个接口:添加商品到购物车、更新购物车商品数、移除购物车商品、查看购物车当中...

  • 常见并发问题

    重复添加购物车 背景 购物车中同一商品只能有一条记录添加购物车时,如果商品已经存在,则在原来的数量上增加;如果不存...

  • 贝塞尔曲线、extern

    如何用贝塞尔曲线做一些商品添加到购物车的动画效果? 上面的效果它可以用 CAShapeLayer + UIBezi...

  • 添加购物车

    商品添加购物车; 先判断当前用户购物车是否存在该商品,若存在就更新当前用的购物车商品数量,若不存在,则新增该商品到...

  • Vue笔记 添加用户,选项卡,购物车加减

    购物车加减效果: 选项卡效果: 添加用户效果:

  • 商城购物流程

    1、商城购物分为方式:加入购物车,立即购买 a)加入购物车:添加多个商品信息(购物车id(主键),商品id,用户i...

网友评论

      本文标题:商品添加购物车效果

      本文链接:https://www.haomeiwen.com/subject/vfmksftx.html