iosanimationWithKeyPath
animationWithKeyPath的值:
transform.scale = 比例轉換
transform.scale.x = 闊的比例轉換
transform.scale.y = 高的比例轉換
transform.rotation.z = 平面圖的旋轉
transform.translation.x
transform.translation.y
transform.translation.z
opacity = 透明度
margin
zPosition
backgroundColor 背景颜色
cornerRadius 圆角
borderWidth
bounds
contents
contentsRect
cornerRadius
frame
hidden
mask
masksToBounds
opacity
position
shadowColor
shadowOffset
shadowOpacity
shadowRadius
Core Animation Programming Guide
- Table of Contents
- Introduction
- Core Animation Basics
- Setting Up Layer Objects
- Animating Layer Content
- Building a Layer Hierarchy
- Advanced Animation Tricks
- Changing a Layer’s Default Behavior
- Improving Animation Performance
- Appendix A: Layer Style Property Animations
- Appendix B: Animatable Properties
- Appendix C: Key-Value Coding Extensions
- Revision History
Key-Value Coding Extensions
Key-Value Coding Compliant Container Classes
The CAAnimation
and CALayer
classes are key-value coding compliant container classes, which means that you can set values for arbitrary keys. Even if the key someKey
is not a declared property of the CALayer
class, you can still set a value for it as follows:
[theLayer setValue:[NSNumber numberWithInteger:50] forKey:@"someKey"]; |
You can also retrieve the value for arbitrary keys like you would retrieve the value for other key paths. For example, to retrieve the value of the someKey
path set previously, you would use the following code:
someKeyValue=[theLayer valueForKey:@"someKey"]; |
OS X Note: The CAAnimation
and CALayer
classes, which automatically archive any additional keys that you set up for instances of those classes, support the NSCoding
protocol.
Default Value Support
Core Animation adds a convention to key value coding whereby a class can provide a default value for a key that has no set value. TheCAAnimation
and CALayer
classes support this convention using the defaultValueForKey:
class method.
To provide a default value for a key, create a subclass of the desired class and override its defaultValueForKey:
method. Your implementation of this method should examine the key parameter and return the appropriate default value. Listing C-1 shows a sample implementation of the defaultValueForKey:
method for a layer object that provides a default value for the masksToBounds
property.
Listing C-1 Example implementation of defaultValueForKey:
+ (id)defaultValueForKey:(NSString *)key |
{ |
if ([key isEqualToString:@"masksToBounds"]) |
return [NSNumber numberWithBool:YES]; |
return [super defaultValueForKey:key]; |
} |
Wrapping Conventions
When the data for a key consists of a scalar value or C data structure, you must wrap that type in an object before assigning it to the layer. Similarly, when accessing that type, you must retrieve an object and then unwrap the appropriate values using the extensions to the appropriate class. Table C-1 lists the C types commonly used and the Objective-C class you use to wrap them.
C type |
Wrapping class |
---|---|
|
|
|
|
|
|
|
|
|
|
Key Path Support for Structures
The CAAnimation
and CALayer
classes lets you access the fields of selected data structures using key paths. This feature is a convenient way to specify the field of a data structure that you want to animate. You can also use these conventions in conjunction with thesetValue:forKeyPath:
and valueForKeyPath:
methods to set and get those fields.
CATransform3D Key Paths
You can use the enhanced key path support to retrieve specific transformation values for a property that contains a CATransform3D
data type. To specify the full key path for a layer’s transforms, you would use the string value transform
or sublayerTransform
followed by one of the field key paths in Table C-2. For example, to specify a rotation factor around the layer’s z axis, you would specify the key pathtransform.rotation.z
.
Field Key Path |
Description |
---|---|
|
Set to an |
|
Set to an |
|
Set to an |
|
Set to an |
|
Set to an |
|
Set to an |
|
Set to an |
|
Set to an |
|
Set to an |
|
Set to an |
|
Set to an |
translation |
Set to an |
The following example shows how you can modify a layer using the setValue:forKeyPath:
method. The example sets the translation factor for the x axis to 10 points, causing the layer to shift by that amount along the indicated axis.
[myLayer setValue:[NSNumber numberWithFloat:10.0] forKeyPath:@"transform.translation.x"]; |
https://developer.apple.com/library/prerelease/ios/releasenotes/General/iOS80APIDiffs/frameworks/QuartzCore.html
https://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/CoreAnimation_guide/Key-ValueCodingExtensions/Key-ValueCodingExtensions.html#//apple_ref/doc/uid/TP40004514-CH12-SW2
转载于:https://www.cnblogs.com/wcLT/p/5194673.html
iosanimationWithKeyPath相关推荐
最新文章
- 解析 Callable Runnable Future 使用和原理
- 局域网内计算机可以互访 无法上互联网,我使用路由器后访问互联网正常,但是网上邻居不能互访,怎么办?...
- java打印 a b c,创建一个java程序,按顺序给出3个术语作为输入(a,b,c)打印它们的根...
- javascript 学习之 数组式的对象
- pytorch深度学习-机器视觉-目标检测和边界框简介
- Android延伸布局到状态栏,Android 状态栏透明
- java拖动图片拼图_求教,我的这个拼图程序中的移动图片的改怎么做
- 关于肺结节检测相关的FROC曲线和目标检测中Precision-Recall曲线,ROC曲线,mAP,AP,APs,APm,APl,AP0.5等的理解。
- [vb]格式输出Format函数
- 体现临床实际基线疾病活动度的早期RA患者中, 治疗起效时间对临床和放射学的影响...
- kali安装火狐浏览器
- php qq邮箱验证码不显示图片,qq邮箱邮件图片不显示怎么解决-解决qq邮箱邮件图片不显示的方法 - 河东软件园...
- 安卓第三方接入登陆-新浪登陆
- ECCV2022论文列表(中英对照)
- 【漏洞学习——SQL】华图教育某分站SQL注入漏洞
- Excel操作技巧:三列内容合并生成到另外一列中;在判断某列里面的值在另外列中是否存在
- xxl-job调度执行器的端口被外部频繁访问造成的错误
- 两数之和(Two Sum)
- 仓库管理怎么做?这5大仓库管理软件能帮到你
- 绿盟科技软件测试招聘,【绿盟科技软件测试面试】面试官很随和-看准网
热门文章
- BizTalk2006的帮助文件又更新了,对于还没有安装BizTalk环境又想学习的,不妨看看帮助先...
- 《LeetCode力扣练习》第5题 C语言版 (做出来就行,别问我效率。。。。)
- 【LeetCode】198.打家劫舍
- mysql5.0 Using a password on the command line interface can be insecure.最简单的解决办法
- java下拉框选择_java中下拉框选项内容
- python获取耗时的shell_python获取耗时的shell_关于Linux:在shell中获取程序执行时间...
- mysql主从读写Windows_Windows操作系统下的MySQL主从复制及读写分离
- sql 只取一条记录_后端程序员必备:书写高质量SQL的30条建议
- js json编辑器_程序员必备编辑器 —— Visual Studio Code
- python列表输入不加逗号_用python打印不带括号或逗号的列表