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的更多相关文章
随机推荐
- 查看真机的系统中sdk的版本
1.adb devices 确保连接上了真机 2.adb shell 进入android系统 3.进入system目录下 4.查看build.prop文件 cat build.prop
- 判断java中两个对象是否相等
java中的基本数据类型判断是否相等,直接使用"=="就行了,相等返回true,否则,返回false. 但是java中的引用类型的对象比较变态,假设有两个引用对象obj1,obj2 ...
- JSon_零基础_005_将po(bean)对象转换为JSon格式的对象字符串,返回给界面
将po(bean)对象转换为JSon格式的对象字符串,返回给界面 导入jar包: 编写po(bean)类: package com.west.webcourse.po; /** * 第01步:编写be ...
- unable to connect to the virtual device Genymotion 神器启动问题
截图: 解决方法:win7以上用户在桌面找到:网络--右键(属性)--更改适配器设置--VirtualBox Host-Only Network--属性--双击:Internet 协议版本4(TCP/ ...
- UINavigationController详解二(转)页面切换和SegmentedController
原文出自:http://blog.csdn.net/totogo2010/article/details/7682433,非常感谢. 1.RootView 跳到SecondView 首先我们需要新一个 ...
- jenkins相关
1. jenkins maven tomcat做持续集成的时候几个关键配置:http://my.oschina.net/congqian/blog/112782?fromerr=PmIDbLs5 2. ...
- 鸟哥的linux私房菜学习记录之bash
当你对计算机输入一个指令时,bash会将指令传送给核心kernel,核心再去调用相关的程序,启动硬件. 如果直接让用户操作操作系统,可能会造成系统的崩溃,所以操作系统通过应用程序来让用户操作系统即壳程 ...
- CentOS修改主机名和网络信息
1.修改主机名称 [root@centos ~]# vim /etc/sysconfig/network打开文件,修改以下内容并保存 NETWORKING=yes #使用网络 HOSTNAME=cen ...
- cornerstone的简单使用
第一步打开工具点击左下角那个加号,弹出的选项中选Add Repository..或者直接点中间显示的Add Repository...是一样的 第二步: 下面填的内容是你经理给你的账号和密码,你只要c ...
- ch2-3:模块的使用-window环境
导入模块:import 模块名 完成如下工作: 1.编写一个小程序testmodule.py,导入新建的模块nester,并定义一个小列表cast,然后使用调用模块中的函数打印列表到屏幕上: impo ...