【问题标题】:CALayer: Custom animatable properties that update built in animatable propertiesCALayer:自定义动画属性,更新内置动画属性
【发布时间】:2015-08-13 22:29:05
【问题描述】:

我在 CAGradientLayer 派生类上创建了一个自定义动画属性,它必须更改 CAGradientLayer 基类上的其他内置动画属性,我想知道最好的方法是什么。目前我正在更新显示方法中的依赖属性:

@implementation CustomGradientLayer

@dynamic myCustomProperty;

+ (BOOL) needsDisplayForKey: (NSString*)aKey
{
    BOOL needsDisplay = [aKey isEqualToString: @"myCustomProperty"];
    if (!needsDisplay)
    {
        needsDisplay = [super needsDisplayForKey: aKey];
    }
    return needsDisplay;
}

- (void) display
{
    CGFloat myCustomProperty = [self.presentationLayer myCustomProperty];


    [CATransaction begin];
    [CATransaction setDisableActions: YES];

    // Update dependant properties on self

    [CATransaction commit];

    [super display];
}

是否可以在不影响底层CALayer 魔法的情况下安全地更新自定义属性设置器中的依赖属性?

【问题讨论】:

  • afaik 你可以使用 KVO

标签: ios objective-c iphone calayer cabasicanimation


【解决方案1】:

我找到了解决方案,但对于任何感兴趣的人,您都可以使用以下方法而不会干扰 CALayar 的东西:

- (void) didChangeValueForKey: (NSString*)aKey (void) didChangeValueForKey: (NSString*)aKey
{
    // Update dependent properties
}

【讨论】:

    猜你喜欢
    • 2011-03-11
    • 2013-06-20
    • 2011-01-24
    • 2011-05-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-04-30
    相关资源
    最近更新 更多