iOS CoreAnimation AnimationWithKeyPath 来改变动画 的Key

本文详细介绍了通过animationWithKeyPath实现的多种动画效果,包括比例转换、旋转和平移等,并提供了具体的CABasicAnimation实例代码。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

可以通过改变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


[objc]  view plain  copy
  1. // Create animation for location change  
  2.        CABasicAnimation *locationAnimation = [CABasicAnimation animationWithKeyPath:@"locations"];  
  3.        locationAnimation.fromValue = gradientMask.locations;  
  4.        locationAnimation.toValue = adjustedLocations;  
  5.        locationAnimation.duration = 0.25;  
  6.          
  7.        // Create animation for color change  
  8.        CABasicAnimation *colorAnimation = [CABasicAnimation animationWithKeyPath:@"colors"];  
  9.        colorAnimation.fromValue = gradientMask.colors;  
  10.        colorAnimation.toValue = adjustedColo  


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值