Key - value coding extension
CoreAnimation
It extends theNSKeyValueCoding
protocol because it is dependentCAAnimation
, andCALayer
class. This extension add some keys default encapsulation extended agreement forCGPoint
,CGRect
,CGSize
,CATransform3D
add key path support
Key - value coding compliant container class
CAAnimation
And theCALayer
class is a container class key compliance - value coding, i.e. the set value can be any key. Even if the key is not inCALayer
the properties declared in the class, you can also set the value in the following manner
[theLayer setValue: @50 forKey: @"someKey"];
You can also get the value corresponding to any key, other keys as to obtain the value corresponding to the same path. as follows
someKeyValue = [theLayer valueForKey: @"someKey"];
Support default values
CoreAnimation
A bond - to add a value coding conventions, i.e., a class can provide a default value for a key, without the set value.CAAnimation
AndCALayer
classes support this convention, through the use ofdefaultValueForKey:
class methods. Provide default values for a key, expectations need to create a subclass of class, while complying withdefaultValueForKey:
class methods. Implementation of this method to check the key parameter and return appropriate default values. The following example
+ (id)defaultValueForKey:(NSString *)key {
if ([key isEqualToString: @"maskToBounds"]) {
return @(YES);
}
return [super defaultValueForKey: key];
}
Package agreed
C language type | Package Type |
---|---|
CGPoint | NSValue |
cgsiz to | NSValue |
CGRect | NSValue |
CATransform3D | NSValue |
CGAffineTransform | NSAffineTransform(OS X only) |
Key path support structure
CAAnimation
AndCALayer
classes allow access path using the key fields of data structure. This feature is more convenient to specify the structure of the field to get the movie you want. BysetValue: forKeyPath:
setting andvalueForKeyPath:
get
[myLayer setValue: @10.0 forKeyPath: @"transform.translation.x"];
CATransform3D
Critical Path
Key path field | description |
---|---|
rotation.x | NSNumber object is disposed, X radians is rotated |
rotation.y | NSNumber object is disposed, Y rotated radians |
rotation.z | NSNumber object is provided, Z radians is rotated |
rotation | Set NSNumber objects, with the same effect rotation.z |
scale.x | NSNumber object is disposed, X stretching factor |
scale.y | NSNumber object is disposed, Y stretching factor |
scale.z | NSNumber object is provided, Z stretching factor |
scale | NSNumber object is provided, three-directional stretch factor |
translation.x | NSNumber object is disposed, X direction movement value |
translation.y | NSNumber object is disposed, Y values to the mobile |
translation.z | NSNumber object is provided, Z value to the mobile |
translation | NSValue provided object (or CGSize comprising NSSize data types), X and Y values to the mobile |
CGPoint
Critical Path
Structure fields | description |
---|---|
x | X value of the point |
Y | Y value of the point |
CGSize
Critical Path
Structure fields | description |
---|---|
width | width |
height | high |
CGRect
Critical Path
Structure fields | description |
---|---|
origin | point |
origin.x | X value |
origin.y | Y value |
size | size |
size.width | width |
size.height | high |