【发布时间】:2012-04-26 16:36:17
【问题描述】:
我通过向 UIView 添加多个图层来组成一种动画。这些图层应通过脚本设置为可见或不可见。
脚本基于实现协议的对象:
// the general protocol for a step
@protocol ActionStep
-(void) applyForTime:(int)playtime;
-(void) reset;
@end
在计时器中,我会遍历步骤对象:
NSEnumerator* enumerator = [ScriptObjects objectEnumerator];
id obj;
while ( obj = [enumerator nextObject] )
{
id <ActionStep> step = obj;
[step applyForTime:currentmilliseconds];
}
一个脚本对象是这个对象:
@interface LayerStep : NSObject <ActionStep>
{
int mTimeOffset;
CGPoint mOffset;
float mAlpha;
LayerObject* mTheLayer;
bool mPrepared;
}
-(id)initWithLayerObject: (LayerObject*) theLayer Milliseconds:(int) milliseconds Offset:(CGPoint) offset Alpha:(float)alpha;
@end
最后我在层中实现了协议:
-(void) applyForTime:(int)playtime
{
if ( mPrepared ) // has the step already been executed?
{
if ( playtime >= mTimeOffset )
{
[mTheLayer setAlpha:mAlpha]; // AssignedLayer.opacity = alpha;
[mTheLayer setPosition:mOffset]; // AssignedLayer.position = offset;
mPrepared = false;
}
}
}
应用步骤中的更改会导致转换。
有没有办法禁用这种转换?我现在根本没有使用任何 CoreAnimation 调用,只是属性本身(参见代码)。
【问题讨论】:
-
我认为我们需要看到更多代码——例如,你是如何进行转换的? “只是属性”是什么意思?
标签: iphone objective-c ios uiview calayer