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

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 CGPointCGRectCGSize, 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.

Table C-1  Wrapper classes for C types

C type

Wrapping class

CGPoint

NSValue

CGSize

NSValue

CGRect

NSValue

CATransform3D

NSValue

CGAffineTransform

NSAffineTransform (OS X only)

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.

Table C-2  Transform field value key paths

Field Key Path

Description

rotation.x

Set to an NSNumber object whose value is the rotation, in radians, in the x axis.

rotation.y

Set to an NSNumber object whose value is the rotation, in radians, in the y axis.

rotation.z

Set to an NSNumber object whose value is the rotation, in radians, in the z axis.

rotation

Set to an NSNumber object whose value is the rotation, in radians, in the z axis. This field is identical to setting therotation.z field.

scale.x

Set to an NSNumber object whose value is the scale factor for the x axis.

scale.y

Set to an NSNumber object whose value is the scale factor for the y axis.

scale.z

Set to an NSNumber object whose value is the scale factor for the z axis.

scale

Set to an NSNumber object whose value is the average of all three scale factors.

translation.x

Set to an NSNumber object whose value is the translation factor along the x axis.

translation.y

Set to an NSNumber object whose value is the translation factor along the y axis.

translation.z

Set to an NSNumber object whose value is the translation factor along the z axis.

translation

Set to an NSValue object containing an NSSize or CGSize data type. That data type indicates the amount to translate in the x and y axis.

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的更多相关文章

随机推荐

  1. android waiting for debugger

    在Studio开发环境中,使用真机开发经常会出现waiting for debugger,卡死不动了,让人很崩溃啊,现在我就总结下几种解决方法,希望能帮到出现同样情况的朋友! 问题出现及解决办法: 多 ...

  2. 夺命雷公狗ThinkPHP项目之----企业网站13之文章列表页的实现(主要是分页的实现)

    列表页这个其实是比较简单的一个,直接遍历除数据即可: public function lists(){ //$mod = M("Article")->select(); // ...

  3. JSP-09-使用EL显示数据

    目的:为了使JSP写起来更加简单. 9.1  EL表达式 ${EL表达式}  :  ${unsername} 操作符:   “. ”操作符: 用来访问对象的属性    ${news.title} “[ ...

  4. 关于centos更新后virtualbox无法使用的问题

    http://blog.csdn.net/zgglj/article/details/50325675

  5. 台电幻彩u盘拆解

  6. 绑定repeater时三目运算加特殊结果处理

    <%#((Convert.ToDouble().ToString() != ).ToString(%

  7. Revit 二次开发 (二) 倾斜的板

    在Revit二次开发过程中,建立一个倾斜的板是可以通过如下方法进行的: // // 摘要: // Creates a slab within the project with the given ho ...

  8. Java 的局部变量和成员变量

    在Java语言中没有全局变量  分析各种变量的作用域的最简单方法是以花括号为界, 1.在类体中定义的是成员变量,成员变量会被默认初始化 2.在方法中定义的是局部变量,局部变量不会被默认初始化

  9. mysql笔记04 MySQL高级特性

    MySQL高级特性 1. 分区表:分区表是一种粗粒度的.简易的索引策略,适用于大数据量的过滤场景.最适合的场景是,在没有合适的索引时,对几个分区进行全表扫描,或者是只有一个分区和索引是热点,而且这个分 ...

  10. USB HID介绍【转】

    本文转载自:http://blog.csdn.net/leo_wonty/article/details/6721214 HID是一种USB通信协议,无需安装驱动就能进行交互,在学习HID之前,先来复 ...