CABasicAnimation animationWithKeyPath 一些规定的值

利用CABasicAnimation制作简单动画 CABasicAnimation制作简单动画CABasicAnimation实例化所用KeyPath以下都是可以针对指定轴(x,y,z轴之一),添加动画效果以下是单一添加动画效果还有一个特例设置动画属性设置动画的Value设置动画次数逆动画回到开始的值添加动画 CABasicAnimation CABasicAnimation是一个类,它继承于CAPropertyAnimation。它可以用来创建... 阅读详情

CABasicAnimation animationWithKeyPath Types

When using the ‘CABasicAnimation’ from the QuartzCore Framework in Objective-C, you have to specify an animationWithKeyPath.  This is a long string and is not easily listed in the CABasicAnimation, CAPropertyAnimation, or the CAAnimation class.  I ended up finding a handy chart within the Core Animation Programming guide in Apple’s iPhone OS Reference Library.  Hope this helps save someone time, at least it will for me.

 

 

 

复制代码
CABasicAnimation *theAnimation;
theAnimation=[CABasicAnimation animationWithKeyPath:@"transform.translation.y"];
theAnimation.delegate = self;
theAnimation.duration = 1;
theAnimation.repeatCount = 0;
theAnimation.removedOnCompletion = FALSE;
theAnimation.fillMode = kCAFillModeForwards;
theAnimation.autoreverses = NO;
theAnimation.fromValue = [NSNumber numberWithFloat:0];
theAnimation.toValue = [NSNumber numberWithFloat:-60]; 
[self.view.layer addAnimation:theAnimation forKey:@"animateLayer"];
复制代码
复制代码
我们可以通过animationWithKeyPath键值对的方式来改变动画
animationWithKeyPath的值:
 
transform.scale = 比例轉換
transform.scale.x = 闊的比例轉換
transform.scale.y = 高的比例轉換
transform.rotation.z = 平面圖的旋轉
opacity = 透明度
 
margin
zPosition
 
backgroundColor
 
cornerRadius
borderWidth

 
bounds
contents

contentsRect
cornerRadius
frame

hidden

mask

masksToBounds
opacity

position

shadowColor

shadowOffset

shadowOpacity
shadowRadius
[self. ui_View.layer removeAllAnimations];
    
    CABasicAnimation *pulse = [CABasicAnimation animationWithKeyPath:@"transform.scale"];
    pulse.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut];
    pulse.duration = 0.5 + (rand() % 10) * 0.05;
    pulse.repeatCount = 1;
    pulse.autoreverses = YES;
    pulse.fromValue = [NSNumber numberWithFloat:.8];
    pulse.toValue = [NSNumber numberWithFloat:1.2];
    [self.ui_View.layer addAnimation:pulse forKey:nil];

// bounds
 
CABasicAnimation *anim = [CABasicAnimation animationWithKeyPath:@"bounds"];
    anim.duration = 1.f;
    anim.fromValue = [NSValue valueWithCGRect:CGRectMake(0,0,10,10)];
    anim.toValue = [NSValue valueWithCGRect:CGRectMake(10,10,200,200)];
    anim.byValue  = [NSValue valueWithCGRect:self. ui_View.bounds]; 
//    anim.toValue = (id)[UIColor redColor].CGColor;
//    anim.fromValue =  (id)[UIColor blackColor].CGColor;
    
    anim.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
    anim.repeatCount = 1;
    anim.autoreverses = YES;
    
    [ui_View.layer addAnimation:anim forKey:nil];
//cornerRadius
 
    CABasicAnimation *anim2 = [CABasicAnimation animationWithKeyPath:@"cornerRadius"];
    anim2.duration = 1.f;
    anim2.fromValue = [NSNumber numberWithFloat:0.f];
    anim2.toValue = [NSNumber numberWithFloat:20.f];
    anim2.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
    anim2.repeatCount = CGFLOAT_MAX;
    anim2.autoreverses = YES;
    
    [ui_View.layer addAnimation:anim2 forKey:@"cornerRadius"];

//contents
 
CABasicAnimation *anim = [CABasicAnimation animationWithKeyPath:@"contents"];
    anim.duration = 1.f;
    anim.fromValue = (id)[UIImage imageNamed:@"1.jpg"].CGImage;
    anim.toValue = (id)[UIImage imageNamed:@"2.png"].CGImage;
//    anim.byValue  = (id)[UIImage imageNamed:@"3.png"].CGImage;
//    anim.toValue = (id)[UIColor redColor].CGColor;
//    anim.fromValue =  (id)[UIColor blackColor].CGColor;
    
    anim.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
    anim.repeatCount = CGFLOAT_MAX;
    anim.autoreverses = YES;
    
    [ui_View.layer addAnimation:anim forKey:nil];


 
[ui_View.layer setShadowOffset:CGSizeMake(2,2)];
    [ui_View.layer setShadowOpacity:1];
    [ui_View.layer setShadowColor:[UIColor grayColor].CGColor];
//
    CABasicAnimation *anim = [CABasicAnimation animationWithKeyPath:@"shadowColor"];
    anim.duration = 1.f;
    anim.toValue = (id)[UIColor redColor].CGColor;
    anim.fromValue =  (id)[UIColor blackColor].CGColor;
    
    anim.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
    anim.repeatCount = CGFLOAT_MAX;
    anim.autoreverses = YES;
    
    [ui_View.layer addAnimation:anim forKey:nil];
    
    CABasicAnimation *_anim = [CABasicAnimation animationWithKeyPath:@"shadowOffset"];
    _anim.duration = 1.f;
    _anim.fromValue = [NSValue valueWithCGSize:CGSizeMake(0,0)];
    _anim.toValue = [NSValue valueWithCGSize:CGSizeMake(3,3)];
    
    _anim.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
    _anim.repeatCount = CGFLOAT_MAX;
    _anim.autoreverses = YES;
    
    [ui_View.layer addAnimation:_anim forKey:nil];
    
    
    CABasicAnimation *_anim1 = [CABasicAnimation animationWithKeyPath:@"shadowOpacity"];
    _anim1.duration = 1.f;
    _anim1.fromValue = [NSNumber numberWithFloat:0.5];
    _anim1.toValue = [NSNumber numberWithFloat:1];
    
    _anim1.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
    _anim1.repeatCount = CGFLOAT_MAX;
    _anim1.autoreverses = YES;
    
    [ui_View.layer addAnimation:_anim1 forKey:nil];
    
    
    
    CABasicAnimation *_anim2 = [CABasicAnimation animationWithKeyPath:@"shadowRadius"];
    _anim2.duration = 1.f;
    _anim2.fromValue = [NSNumber numberWithFloat:10];
    _anim2.toValue = [NSNumber numberWithFloat:5];
    
    _anim2.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
    _anim2.repeatCount = CGFLOAT_MAX;
    _anim2.autoreverses = YES;
    
    [ui_View.layer addAnimation:_anim2 forKey:nil];
复制代码

 

 

 

 

 

几个可以用来实现热门APP应用PATH中menu效果的几个方法

+(CABasicAnimation *)opacityForever_Animation:(float)time //永久闪烁的动画

{

    CABasicAnimation *animation=[CABasicAnimation animationWithKeyPath:@"opacity"];

    animation.fromValue=[NSNumber numberWithFloat:1.0];

    animation.toValue=[NSNumber numberWithFloat:0.0];

    animation.autoreverses=YES;

    animation.duration=time;

    animation.repeatCount=FLT_MAX;

    animation.removedOnCompletion=NO;

    animation.fillMode=kCAFillModeForwards;

    return animation;

}

 

+(CABasicAnimation *)opacityTimes_Animation:(float)repeatTimes durTimes:(float)time; //有闪烁次数的动画

{

    CABasicAnimation *animation=[CABasicAnimation animationWithKeyPath:@"opacity"];

    animation.fromValue=[NSNumber numberWithFloat:1.0];

    animation.toValue=[NSNumber numberWithFloat:0.4];

    animation.repeatCount=repeatTimes;

    animation.duration=time;

    animation.removedOnCompletion=NO;

    animation.fillMode=kCAFillModeForwards;

    animation.timingFunction=[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn];

    animation.autoreverses=YES;

    return  animation;

}

 

+(CABasicAnimation *)moveX:(float)time X:(NSNumber *)x //横向移动

{

    CABasicAnimation *animation=[CABasicAnimation animationWithKeyPath:@"transform.translation.x"];

    animation.toValue=x;

    animation.duration=time;

    animation.removedOnCompletion=NO;

    animation.fillMode=kCAFillModeForwards;

    return animation;

}

 

+(CABasicAnimation *)moveY:(float)time Y:(NSNumber *)y //纵向移动

{

    CABasicAnimation *animation=[CABasicAnimation animationWithKeyPath:@"transform.translation.y"];

    animation.toValue=y;

    animation.duration=time;

    animation.removedOnCompletion=NO;

    animation.fillMode=kCAFillModeForwards;

    return animation;

}

 

+(CABasicAnimation *)scale:(NSNumber *)Multiple orgin:(NSNumber *)orginMultiple durTimes:(float)time Rep:(float)repeatTimes //缩放

{

    CABasicAnimation *animation=[CABasicAnimation animationWithKeyPath:@"transform.scale"];

    animation.fromValue=orginMultiple;

    animation.toValue=Multiple;

    animation.duration=time;

    animation.autoreverses=YES;

    animation.repeatCount=repeatTimes;

    animation.removedOnCompletion=NO;

    animation.fillMode=kCAFillModeForwards;

    return animation;

}

 

+(CAAnimationGroup *)groupAnimation:(NSArray *)animationAry durTimes:(float)time Rep:(float)repeatTimes //组合动画

{

    CAAnimationGroup *animation=[CAAnimationGroup animation];

    animation.animations=animationAry;

    animation.duration=time;

    animation.repeatCount=repeatTimes;

    animation.removedOnCompletion=NO;

    animation.fillMode=kCAFillModeForwards;

    return animation;

}

 

+(CAKeyframeAnimation *)keyframeAniamtion:(CGMutablePathRef)path durTimes:(float)time Rep:(float)repeatTimes //路径动画

{

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

    animation.path=path;

    animation.removedOnCompletion=NO;

    animation.fillMode=kCAFillModeForwards;

    animation.timingFunction=[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn];

    animation.autoreverses=NO;

    animation.duration=time;

    animation.repeatCount=repeatTimes;

    return animation;

}

 

+(CABasicAnimation *)movepoint:(CGPoint )point //点移动

{

    CABasicAnimation *animation=[CABasicAnimation animationWithKeyPath:@"transform.translation"];

    animation.toValue=[NSValue valueWithCGPoint:point];

    animation.removedOnCompletion=NO;

    animation.fillMode=kCAFillModeForwards;

    return animation;

}

 

+(CABasicAnimation *)rotation:(float)dur degree:(float)degree direction:(int)direction repeatCount:(int)repeatCount //旋转

{

    CATransform3D rotationTransform  = CATransform3DMakeRotation(degree, 0, 0,direction);

    CABasicAnimation* animation;

    animation = [CABasicAnimation animationWithKeyPath:@"transform"];

 

animation.toValue= [NSValue valueWithCATransform3D:rotationTransform];

    animation.duration= dur;

animation.autoreverses= NO;

    animation.cumulative= YES;

    animation.removedOnCompletion=NO;

    animation.fillMode=kCAFillModeForwards;

    animation.repeatCount= repeatCount; 

animation.delegate= self;

 

return animation;

}

 

 

 

 

 

实现view放大再缩小的效果

复制代码
- (void)viewDidLoad {

    [super viewDidLoad];


layer=[CALayer layer];

layer.frame=CGRectMake(50, 200, 50, 50);

layer.backgroundColor=[UIColor orangeColor].CGColor;

layer.cornerRadius=8.0f;


CABasicAnimation *animation=[CABasicAnimation animationWithKeyPath:@"transform.translation.y"];

animation.duration=4.0f;

animation.autoreverses=NO;

animation.repeatCount=1;

animation.toValue=[NSNumber numberWithInt:-10];

animation.fromValue=[NSNumber numberWithInt:200];

animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];


CABasicAnimation *animationZoomIn=[CABasicAnimation animationWithKeyPath:@"transform.scale"];

animationZoomIn.duration=2.0f;

animationZoomIn.autoreverses=NO;

animationZoomIn.repeatCount=1;

animationZoomIn.toValue=[NSNumber numberWithFloat:1.56];

animationZoomIn.timingFunction=[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn];

CABasicAnimation *animationZoomOut=[CABasicAnimation animationWithKeyPath:@"transform.scale"];

animationZoomOut.beginTime=2.0f;

animationZoomOut.duration=2.0f;

animationZoomOut.autoreverses=NO;

animationZoomOut.repeatCount=1;

animationZoomOut.toValue=[NSNumber numberWithFloat:.01];

animationZoomOut.timingFunction=[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut];

CAAnimationGroup *group=[CAAnimationGroup animation];

group.duration=4.0f;

group.animations=[NSArray arrayWithObjects: animation, animationZoomIn, animationZoomOut,nil];

group.removedOnCompletion=NO;

group.fillMode=kCAFillModeForwards;

[layer addAnimation:group forKey:nil];

[self.view.layer addSublayer:layer];


//layer.hidden=YES;

}
AI辅助编程实战指南:从提示工程到开发环境搭建 大型语言模型(LLM)作为现代人工智能的核心技术,通过自然语言理解和生成能力,正在深刻改变软件开发范式。其原理基于海量代码和文本数据的预训练,能够根据上下文生成符合逻辑的代码片段和解决方案。这一技术的核心价值在于将开发者从繁琐的语法和基础逻辑编写中解放出来,提升开发效率与代码质量。在实际工程应用中,AI辅助编程已广泛应用于日常编码、代码调试、文档生成和系统设计等场景。其中,提示工程(Prompt Engineering)和检索增强生成(RAG)是两项关键技术:前者通过结构化、角色化的指令设计,引导AI生成更 阅读详情

相关推荐

fpga进阶--时序约束

1、基础概念 1.1 建立(setup)/保持(hold)时间 上述的锁存沿会将数据保存下来,但是必须要满足一定的条件: 建立时间Tsu:在时钟有效沿之前,数据必须保持稳定的最小时间; 保持时间Th:在时钟有效沿之后,数据必须保持稳定的最小时间; 1.2 亚稳态(Metastability) 亚稳态是由于违背了触发器的建立和保持时间而产生的,设计中任何一个触发器都有特定的建立和保持时间,在时钟上升沿前后的这段时间窗口内,数据输入信号必须保持稳定。如果信号在这段时间内发生了变化,那么输...

HHH的博客 2443

CABasicAnimation之animationWithKeyPath方法

CABasicAnimation中可以用animationWithKeyPath类方法来创建动画.其中keyPath的值有以下若干.transform.scale = 比例转换transform.scale.x = 闊的比例转换transform.scale.y = 高的比例转换transform.rotation.z = 平面图的转换opacity = 透明度margin = 布局zPositi...

时光的博客 1626

智能座舱通信技术解析:从CAN总线到车载以太网与V2X

在汽车电子与智能网联快速融合的背景下,座舱智能化已不再是简单的屏幕堆砌,而是依赖底层通信技术构建的复杂系统。CAN总线因高可靠性与确定性传输,持续承担车身控制与安全信号的传递;车载以太网则凭借高带宽优势,成为多屏高清视频与OTA升级的核心通道;V2X车路协同技术进一步将座舱与外界的实时信息互联。理解这些技术的分工协作,是掌握智能座舱架构、开展座舱测试与故障排查的关键。本文从实际测试经验出发,梳理不同总线在座舱内部及外部的应用逻辑,结合低成本的实验台架搭建指南,展示从信号采集、网关转发到多媒体流传输的完整链路

weixin_29284657的博客 345

一些常用的animationWithKeyPath值的总结

2019独角兽企业重金招聘Python工程师标准>>> ...

weixin_33978016的博客 342

Microsoft Visual C++ 14.0 is required 的亲测最全解决方案(包括安装包丢失或损坏解决方法)

在用python调用别的语言(我用的是cache数据库)的方法时,在执行"python setup3.py install"方法时出现“error: Microsoft Visual C++ 14.0 is required. Get it with “Microsoft Visual C++ Build Tools”错误,以下是网上能找到的安装过程中“所有”解决方案: 1、首先需要下载Micr...

CDL2017CDL的博客 2万+

别再让OCV拖慢你的芯片!手把手教你用set_timing_derate优化STA时序(附CPPR实战)

本文深入探讨了芯片设计中OCV(On-Chip Variation)对时序分析的影响,并提供了使用`set_timing_derate`优化STA时序的实战指南。通过分阶段derate设置和CPPR技术,有效减少时序违例,提升芯片性能。文章结合TSMC 7nm工艺案例,详细解析了OCV建模与优化策略,助力工程师实现时序收敛。

weixin_42525005的博客 306

动画学习 iOS

CABasicAnimation——基本动画 CABasicAnimation *moveAnimation = [CABasicAnimation animationWithKeyPath:@"position.y"]; moveAnimation.duration = 0.8;//动画时间 //动画起始值和终止值的设置 moveAnimation.fromValue ...

qq_44865905的博客 341

Matplotlib图片尺寸调整全攻略:从figsize到savefig的实战技巧

在数据可视化与科学计算中,图形尺寸控制是影响图表可读性与专业度的基础环节。其核心原理在于协调逻辑尺寸(英寸)与物理输出(像素)的映射关系,这直接决定了信息呈现的清晰度与布局合理性。从技术价值看,精准的尺寸控制能提升图表在不同媒介(如学术论文、报告、网页)中的适配性,避免显示不全、模糊失真等常见问题。在应用场景上,无论是Jupyter Notebook中的交互探索、自动化报告的批量生成,还是满足严格出版要求的插图制作,都需要掌握对应的尺寸调整策略。本文聚焦于matplotlib中的figsize参数、rcPa

weixin_30899023的博客 331

CABasicAnimation animationWithKeyPath 一些规定的值

CABasicAnimation   animationWithKeyPath   Types When using the ‘CABasicAnimation’ from the QuartzCore Framework in Objective-C, you have to specify an animationWithKeyPath.  This is a long string

人只活一次,把握梦想吧 896

【图形学】Loop细分算法及半边结构实现(C++)

文章目录Loop 细分算法介绍增加新顶点更新旧顶点算法实现半边结构半边结构的表示方法半边结构的构造方法创建所有顶点创建所有面及半边半边结构的使用 Loop 细分 顾名思义,网格细分是将粗糙网格精细化的过程,如下动图。Loop细分是众多网格细分算法的一种,Loop细分仅仅对三角形网格模型有效。值得注意的是,虽然叫Loop细分,但是不能理解为“循环”细分,叫这个名字是因为作者的名字是这个而已。 下面是一个粗糙的兔子模型1000个面,进行3次细分 算法介绍 Loop细分算法主要分两步进行 增加新顶点:增加

wk_119的博客 8069

Electron多窗口开发避坑指南:Pinia状态同步的3种解决方案对比

本文深入探讨了在Electron多窗口应用中实现Pinia状态同步的三种核心方案。针对Electron多窗口架构下状态隔离的挑战,文章对比了基础事件通信、共享存储以及智能Pinia插件等方案的优劣与适用场景,并提供了生产级的实现指南与选型建议,帮助开发者构建健壮高效的桌面应用。

spice的博客 479

iOS:CABasicAnimation animationWithKeyPath 一些规定的值

CABasicAnimation animationWithKeyPath 一些规定的值 CABasicAnimation animationWithKeyPath Types When using the ‘CABasicAnimation’ from the QuartzCore Framework in Objective-C, you have to specify an

小五 1486

N5105核显直通PVE:从黑屏到HDMI输出的完整指南

PCI直通能让虚拟机独占物理设备,但核显直通远没有独显那么轻松。Intel核显与CPU、显示输出链路的强耦合使UEFI引导、GOP驱动、驱动签名等环节都成了黑屏陷阱。在PVE虚拟化环境中,通过IOMMU开启、vfio-pci绑定、OVMF固件和Q35机型配合,可以绕过KVM检测,让Windows虚拟机正确驱动核显,从HDMI口输出画面,并解锁Intel Quick Sync硬解能力。这种方案尤其适合N5105等低功耗迷你主机,可作为客厅HTPC、本地视频硬解或依赖硬件加速的轻量工作台。本文基于N5105平台

weixin_31082403的博客 379

【转】CABasicAnimation animationWithKeyPath 一些规定的值

转自:http://blog.sina.com.cn/s/blog_53e2ac4d0100qoke.htmlCABasicAnimation animationWithKeyPath TypesWhen using the ‘CABasicAnimation’ from the QuartzCore Framework in Objective-C, you have to spec...

dishuangqing3232的博客 162

复分析 阿尔福斯(Ahlfors) 第三版答案 英文

答案分为十章,有部分习题没有答案,全英文复分析阿尔福斯(Ahlfors) 第三版答案

VB摄像头监控

该VB模块可对摄像头捕获的画面进行录像等,可在创建的窗口进行控制

上一篇: KVO
下一篇: CATransform3D 矩阵变换之立方体旋转实现细节
celljay
博客等级 码龄15年 1粉丝 7原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值