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
Core Animation extends the NSKeyValueCoding protocol as it pertains to the CAAnimation and CALayer classes. This extension adds default values for some keys, expands wrapping conventions, and adds key path support for CGPoint, CGRect, CGSize, andCATransform3D types.
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
iosanimationWithKeyPath的更多相关文章
随机推荐
- Eclipse下Ruby的配置]
简述: 在Eclipse中开发Ruby开发环境 步骤: 第一步, 1. 在Eclipse的Help -> Install New Software输入 http://download. ...
- 夺命雷公狗—angularjs—13—post参数的接收发送
我们强悍的angularjs为我们不仅仅提供了他的get接收方式,而且也有post的接收方式,我们现在做一个模拟接收后端传递过来的json的数据: <?php $arr = ['user'=&g ...
- linux系统中grub配置文件
安装了Windows和Linux时肯定要通过GRUB进行引导,GRUB引导器的主配置文件路径/boot/grub/grub.conf(也可能是/boot/grub2/grub.conf),以#号开头的 ...
- linux下在eclipse上运行hadoop自带例子wordcount
启动eclipse:打开windows->open perspective->other->map/reduce 可以看到map/reduce开发视图.设置Hadoop locati ...
- android自定义view属性
第一种 /MainActivity/res/values/attrs.xml <?xml version="1.0" encoding="utf-8"?& ...
- rqnoj-342-最不听话的机器人-dp
dp[i][j][k][[l]: 执行第i步,执行到点(j,k),方向为l时,用的最大步数. 状态转移根据step[i]转移. #include<stdio.h> #include< ...
- 如何在图像处理工具包ImagXpress中对图像进行捕捉、复制和粘贴
如何在在ImagXpress中进行图像的捕捉. 复制和粘贴呢?下面详细来看一下,在多种情况下,图和实现这些操作. 捕捉屏幕图像 捕捉通过ImageXView窗口绑定的屏幕范围,以及保存到一个Image ...
- 160826、浏览器渲染页面过程描述,DOM编程技巧以及重排和重绘
一.浏览器渲染页过程描述 1.浏览器解析html源码,然后创建一个DOM树. 在DOM树中,每一个HTML标签都有一个对应的节点(元素节点),并且每一个文本也都有一个对应的节点(文本节点). DO ...
- 【Pro ASP.NET MVC 3 Framework】.学习笔记.3.MVC的主要工具-单元测试
IProductRepository接口定义了一个仓库,我们通过它获得.更新Product对象.IPriceReducer接口指定了一个功能,它将要对所有的Products实施,通过一个参数,降低他们 ...
- hdwiki 在IIS 下的伪静态
HDwiki有SEO设置的功能,此功能可以将HDwiki的页面进行URL静态化转换,从而使HDwiki内容更容易被搜索引擎挖掘,提高被收录的机率.注意事项 1.本功能对服务器环境有特殊要 ...