iphone ios CABasicAnimation animationWithKeyPath 一些规定的值

本文详细介绍了如何使用CoreAnimation通过关键路径访问结构体字段,包括旋转、缩放、平移等,以及如何设置和获取这些结构体的值。

原文:

https://developer.apple.com/library/ios/#documentation/Cocoa/Conceptual/CoreAnimation_guide/Articles/KVCAdditions.html

 

 

Key Path Support for Structure Fields

 

CAAnimation provides support for accessing the fields of selected structures using key paths. This is useful for specifying these structure fields as the key paths for animations, as well as setting and getting values usingsetValue:forKeyPath: and valueForKeyPath:.

CATransform3D exposes the following fields:

Structure Field

Description

rotation.x

The rotation, in radians, in the x axis.

rotation.y

The rotation, in radians, in the y axis.

rotation.z

The rotation, in radians, in the z axis.

rotation

The rotation, in radians, in the z axis. This is identical to setting the rotation.z field.

scale.x

Scale factor for the x axis.

scale.y

Scale factor for the y axis.

scale.z

Scale factor for the z axis.

scale

Average of all three scale factors.

translation.x

Translate in the x axis.

translation.y

Translate in the y axis.

translation.z

Translate in the z axis.

translation

Translate in the x and y axis. Value is an NSSize or CGSize.

CGPoint exposes the following fields:

Structure Field

Description

x

The x component of the point.

y

The y component of the point.

CGSize exposes the following fields:

Structure Field

Description

width

The width component of the size.

height

The height component of the size.

CGRect exposes the following fields:

Structure Field

Description

origin

The origin of the rectangle as a CGPoint.

origin.x

The x component of the rectangle origin.

origin.y

The y component of the rectangle origin.

size

The size of the rectangle as a CGSize.

size.width

The width component of the rectangle size.

size.height

The height component of the rectangle size.

You can not specify a structure field key path using Objective-C 2.0 properties. This will not work:

    myLayer.transform.rotation.x=0;

Instead you must use setValue:forKeyPath: or valueForKeyPath: as shown below:

    [myLayer setValue:[NSNumber numberWithInt:0] forKeyPath:@"transform.rotation.x"];

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值