x轴缩放:
CABasicAnimation *theAnimation;
theAnimation=[CABasicAnimation animationWithKeyPath:@"transform.scale.x"];
theAnimation.duration=8;
theAnimation.removedOnCompletion = YES;
theAnimation.fromValue = [NSNumber numberWithFloat:1];
theAnimation.toValue = [NSNumber numberWithFloat:0.5];
 [yourView.layer addAnimation:theAnimation forKey:@"animateTransform"];

y轴缩放:
CABasicAnimation *theAnimation;
theAnimation=[CABasicAnimation animationWithKeyPath:@"transform.scale.y"];
theAnimation.duration=8;
theAnimation.removedOnCompletion = YES;
theAnimation.fromValue = [NSNumber numberWithFloat:1];
theAnimation.toValue = [NSNumber numberWithFloat:0.5];
 [yourView.layer addAnimation:theAnimation forKey:@"animateTransform"];

x轴,y轴同时按比例缩放:
CABasicAnimation *theAnimation;
theAnimation=[CABasicAnimation animationWithKeyPath:@"transform.scale"];
theAnimation.duration=8;
theAnimation.removedOnCompletion = YES;
theAnimation.fromValue = [NSNumber numberWithFloat:1];
theAnimation.toValue = [NSNumber numberWithFloat:0.5];
 [yourView.layer addAnimation:theAnimation forKey:@"animateTransform"];

以上缩放是以view的中心点为中心缩放的,如果需要自定义缩放点,可以设置卯点:
//中心点
[yourView.layer setAnchorPoint:CGPointMake(0.5, 0.5)];

//左上角
[yourView.layer setAnchorPoint:CGPointMake(0, 0)];

//右下角
[yourView.layer setAnchorPoint:CGPointMake(1, 1)];

转载于:https://www.cnblogs.com/XXxiaotaiyang/p/5043327.html

iOS layer 动画相关推荐

  1. iOS动画编程-Layer动画[ 2 ] Getting Started with Layer Animations

    本节将介绍CALayer与Core Animation基础,找找通过Layer操作动画的感觉,你将学到如何移动.隐藏显示Layer的方法 animation properties Layer中很多动画 ...

  2. iOS核心动画学习整理

    最近利用业余时间终于把iOS核心动画高级技巧(https://zsisme.gitbooks.io/ios-/content/chapter1/the-layer-tree.html)看完,对应其中一 ...

  3. iOS 核心动画 Core Animation浅谈

    代码地址如下: http://www.demodashi.com/demo/11603.html 前记 关于实现一个iOS动画,如果简单的,我们可以直接调用UIView的代码块来实现,虽然使用UIVi ...

  4. ios uiview动画_iOS UIView动画

    ios uiview动画 In this tutorial, we'll be animating our UI Views in various ways in the iOS Applicatio ...

  5. iOS核心动画详解swift版----基础动画

    2019独角兽企业重金招聘Python工程师标准>>> iOS核心动画详解swift版---基础动画 创建工程,添加2个ViewController,通过rootViewContro ...

  6. iOS 文字动画,文字逐个显示

    随手记: 对于iOS文字动画,首先想到的应该是基于CoreText框架将文字每个都写出来,加上定时器给定每个字显示的时间,这是一种思维方式: #import "ViewController. ...

  7. 如何实现iOS图书动画-第2部分(上)

    原文链接 : How to Create an iOS Book Open Animation: Part 2 原文作者 : Vincent Ngo 译文出自 : 开发技术前线 www.devtf.c ...

  8. BasicAnimation:纯Swift的基础动画库,支持 iOS 属性动画:缩放、旋转、平移、背景颜色、透明度、阴影等和弹性动画

    BasicAnimation https://github.com/ZuopanYao/BasicAnimation iOS 属性动画:缩放.旋转.平移.背景颜色.透明度.阴影等,一句代码的事 支持以 ...

  9. iOS 简单动画汇总

    iOS 简单动画主要分为三种(这是我的理解): 第一种:改变位置,大小等 //开始动画 [UIView beginAnimations:nil context:nil]; //设定动画持续时间 [UI ...

最新文章

  1. php待办事项设计,如何为待办事项列表应用程序设计ViewModel?
  2. http服务器 如何传输文件,http服务器 如何传输文件
  3. OpenGL屏幕空间环境光遮挡
  4. php 输出的区别,php的6种输出方式的区别_后端开发
  5. 如何验证python的下载安装_如何下载python并正确安装
  6. 20年,只有谷歌曾经不同
  7. E. 数好多好多猴(南阳理工oj—21新生第二场招新赛)
  8. 华为再获90天“临时许可证” 可继续维护客户
  9. IVF和VS安装——配置Fortran环境
  10. adobe reader XI 打开后闪退(或过几秒后自动退出)【解决方案】
  11. RK3568平台开发系列讲解(环境篇)RK3568 SDK Linux编译服务器开发坏境搭建
  12. 微信第三方平台服务商各种坑必读(有问必答)授权事件接收配置,消息与事件接收配置
  13. MySQL 5.7.37数据库下载安装教程(Windows无需安装版)
  14. iTRON新闻大集合
  15. iOS开发-QQ好友列表展示
  16. java输入语句怎么写
  17. AGM FPGA之AG10K 系列的开发建议(连载二)
  18. 【算法详解】如何使用递归,递归使用的技巧详解
  19. 三年80个用3dmax建模会遇到的问题,入门基础和老手都会遇到的问题及解答
  20. 如何免费参加高端大气上档次的 COSCon'19 ?

热门文章

  1. 用vi在linux下查看16进制文件
  2. MS SQL入门基础:数据库中的锁
  3. sh: 0: getcwd() failed: No such file or directory解决
  4. yelee博客的busuanzi访客统计失效问题解决
  5. 计算机组成要素五:虚拟机 堆栈模型
  6. mysql bitmap redis_Redis中bitmap的妙用
  7. 华为平板解锁工具_2020年备战考研必选8款平板电脑 平板电脑推荐(12月最新版)...
  8. 四格漫画《MUXing》——度姐传说
  9. 接口报错mixed content blocked
  10. JDBC连接不同数据库的连接参数