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. sql递归查询子级

    WITH T(emp_no, name, dept_no, the_level, path,path1,manager_id) AS( SELECT emp_no, name, dept_no ,1 ...

  2. iOS:制作九宫格

    制作简单的九宫格: 源码如下: #import "ViewController.h" @interface ViewController () @end @implementati ...

  3. Windows Server上用于iSCSI的网卡的必备设置

    如下的修改是iSCSI网卡的推荐配置, 新装起来的Host不要忘记改起来哦. 其原理是强制走iSCSI通讯的网卡立即对到来的TCP报文(segment)做出acknowledge, 从而解决iSCSI ...

  4. 树行控件TreeView 在WinForm下 怎么实现重命名功能

    public Form1() {     InitializeComponent();     this.Load+=new EventHandler(Form1_Load);     treeVie ...

  5. ftp 命令行操作 经常使用命令

    > ftp <host> [port] > pwd  # 查看当前文件夹 > dir  # 查看FTPserver中的文件及文件夹 > mkdir <dirn ...

  6. Sql Server-查询一列的数据进行拼接

    select convert(VARCHAR(10),memberid) +',' from t_member where teamid = 1009 for xml path('')

  7. simple-libfm-example-part1

    原文:https://thierrysilbermann.wordpress.com/2015/02/11/simple-libfm-example-part1/ I often get email ...

  8. 成员函数的const究竟修饰的是谁

    demo <pre name="code" class="cpp">class Test { public: const void OpVar(in ...

  9. 栅格计算器函数之Con

    Con函数是condition(条件)的缩写,其作用 语法是: Con(条件,条件为真执行语句,条件为假执行语句[可选]) 或Con(输入栅格,条件为真执行语句,条件为假执行语句[可选],逻辑表达式) ...

  10. Silverlight 之 浅析

    一.silverlight定义及作用 silverlight用XAML来做前端界面,用.NET或者JS作为程序脚本支持,在浏览器内外运行的应用.可以认为和FLASH 和ADOBE AIR有很大的功能重 ...