1. #pragma mark - 添加到购物车的动画效果
  2. // huangyibiao
  3. - (void)addAnimatedWithFrame:(CGRect)frame {
  4. // 该部分动画 以self.view为参考系进行
  5. frame = [[UIApplication sharedApplication].keyWindow  convertRect:frame fromView:self.RFcell.headBtn];
  6. UIButton *move = [[UIButton alloc] initWithFrame:frame];
  7. [move setBackgroundColor:UIColorFromRGB(0xFFA215)];
  8. [move setTitle:self.RFcell.headBtn.currentTitle forState:UIControlStateNormal];
  9. [move setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
  10. move.contentMode = UIViewContentModeScaleToFill;
  11. [[UIApplication sharedApplication].keyWindow addSubview:move];
  12. // 加入购物车动画效果
  13. [UIView animateWithDuration:1.2 animations:^{
  14. move.frame = CGRectMake(320 - frame.size.width  - 20, 24,
  15. frame.size.width, frame.size.height);
  16. } completion:^(BOOL finished) {
  17. [move removeFromSuperview];
  18. if (self.cartCategoriesLabel == nil) {
  19. self.cartCategoriesLabel = [[UILabel alloc] initWithFrame:CGRectMake((16 - 8) / 2, (16 - 8) / 2, 8, 8)];
  20. self.cartCategoriesLabel .textColor = [UIColor whiteColor];
  21. self.cartCategoriesLabel .backgroundColor = [UIColor clearColor];
  22. self.cartCategoriesLabel .textAlignment = NSTextAlignmentCenter;
  23. self.cartCategoriesLabel .font = [UIFont systemFontOfSize:9];
  24. UIImageView *imgView = [[UIImageView alloc] initWithFrame:CGRectMake(15, 8, 16, 16)];
  25. imgView.image = [UIImage imageNamed:@"news"];
  26. [imgView addSubview:self.cartCategoriesLabel];
  27. [self.cartButton addSubview:imgView];
  28. }
  29. self.cartCategoriesLabel .text = [NSString stringWithFormat:@"%d", _cartCategories.count];
  30. }];
  31. return;
  32. }

frame参数是按钮的frame,也就是原来所在父视图上的Frame

这里会将原来的frame转换成window上的frame

在动画完成后,更新显示购物车中的商品种类数

iOS添加到购物车的简单动画效果的更多相关文章

  1. 原生JS封装简单动画效果

    原生JS封装简单动画效果 一致使用各种插件,有时候对原生JS陌生了起来,所以决定封装一个简单动画效果,熟悉JS原生代码 function animate(obj, target,num){ if(ob ...

  2. iOS CAShapeLayer、CADisplayLink 实现波浪动画效果

    iOS CAShapeLayer.CADisplayLink 实现波浪动画效果 效果图 代码已上传 GitHub:https://github.com/Silence-GitHub/CoreAnima ...

  3. ios开发之--简单动画效果的添加

    记录一个简单的动画效果,自己写的,很简单,仅做记录. 附一个demo的下载地址: https://github.com/hgl753951/hglTest.git 代码如下: 1,准备 BOOL _i ...

  4. iOS开发——实用技术OC篇&简单抽屉效果的实现

    简单抽屉效果的实现 就目前大部分App来说基本上都有关于抽屉效果的实现,比如QQ/微信等.所以,今天我们就来简单的实现一下.当然如果你想你的效果更好或者是封装成一个到哪里都能用的工具类,那就还需要下一 ...

  5. jQuery之简单动画效果

    1. show()显示动画 语法:show(speed,callback) Number/String,Function speend为动画执行时间,单位为毫秒.也可以为slow",&quo ...

  6. JQuery(二)——简单动画效果

    上一篇博客总结了JQuery的一些基本知识,这篇博客重点从JQuery能够制造各种各样的网页效果方面来进行总结.总结一些常见的常用的基本效果的必备方法.从隐藏显示,淡入淡出,滑动,动画等几个方面来简单 ...

  7. 【Demo】jQuery 轮播图简单动画效果

    功能实现: (1)设定图片称号的鼠标悬停事件: (2)在事件中利用自定义动画函数调整显示图片,并修改对应标号样式: (3)为图片显示区域设定鼠标悬停事件: (4)当鼠标停在该区域时,清除图片切换动画定 ...

  8. iOS简单动画效果:闪烁、移动、旋转、路径、组合

    #define kDegreesToRadian(x) (M_PI * (x) / 180.0) #define kRadianToDegrees(radian) (radian*180.0)/(M_ ...

  9. android 给LinearLayout中添加一定数量的控件,并让着一定数量的控件从右到左移动,每隔若干秒停顿一下,最后一个view链接第一个view,然后继续移动循环往复,形成一个死循环简单动画效果

    主类:IndexAnimationLinearLayout.java package com.yw.sortlistview; import java.util.ArrayList; import j ...

随机推荐

  1. mysql错误日志/var/log/mariadb/mariadb.log,二进制日志

    mariadb-日志 IT_luo关注0人评论65人阅读2018-10-15 08:59:03   mariadb日志 mariadb日志: 1.查询日志:query log: 2.慢查询日志:slo ...

  2. 3D几何图形的生成算法

    在之前的博客上,发布了一个我写的3D几何图形生成的DEMO: http://www.cnblogs.com/WhyEngine/p/3415040.html DEMO下载地址: http://file ...

  3. zoj 2860 四边形优化dp

    Breaking Strings Time Limit: 2 Seconds        Memory Limit: 65536 KB A certain string-processing lan ...

  4. mysql必知必会(四、检索数据,五、排序检索数据,六、过滤数据,七、数据过滤)

    四.select语句 1.检索单个列 select prod_name from products; 2.检索多个列 select prod_name, prod_price from product ...

  5. Volley框架的介绍使用

    Volley是在2013年的Google I/O 2013大会上发布的,是我们的网络通信更快,更简单,更方便.对于初学者来讲是一个很好的框架. 简单来说,它提供了如下的便利功能: JSON,图像等的异 ...

  6. Spark性能优化:数据倾斜调优

    前言 继<Spark性能优化:开发调优篇>和<Spark性能优化:资源调优篇>讲解了每个Spark开发人员都必须熟知的开发调优与资源调优之后,本文作为<Spark性能优化 ...

  7. Angular6

    Structural Directives https://angular.io/guide/structural-directives#template-input-variable There a ...

  8. Idea代码可视化插件

    Idea代码可视化插件 https://plugins.jetbrains.com/plugin/7324-code-iris

  9. 直接修改class文件内容即使是文本会导致App异常,正确方式是修改java再用生成的class替换掉原有的class

    前几天来了个小任务,把某项目中某人的邮件地址改了下. 由于对项目不熟悉,于是采用find方式找出app中所有包含某人邮件地址的文件都找出来了. xml,properties大约三四个,还有两个clas ...

  10. TotalCommander如何比较文件夹并提取出重复的文件

    1 如图所示,我左侧有一万本多小说,右侧有两千五百多本小说,我希望比较这两个文件夹相同的小说并剪切到一个新的文件夹中. 2 我们使用Total Commander对比这两个文件夹 3 随后两个文件夹相 ...