0

ios CALayer 委托 displayLayer 未调用

来自: http: //mysterycoconut.com/blog/2011/01/cag1/

- (id)initWithCoder:(NSCoder *)aDecoder;
{
    if (self = [super initWithCoder:aDecoder])
    {
        MyLayer* _myLayer = [MyLayer layerWithImage:img sampleSize:fSize];
        _myLayer.delegate = self;

        CABasicAnimation *anim = [CABasicAnimation animationWithKeyPath:@"imageIndex"];
        anim.fromValue = [NSNumber numberWithInt:1];
        anim.toValue = [NSNumber numberWithInt:5];
        anim.duration = 2f;
        anim.repeatCount = 1;
        [richter addAnimation:anim forKey:nil];

        [self.view.layer addSublayer:_myLayer];

    }
    return self;
}

// CALayer delegate needs this method for variable sample size to work
- (void)displayLayer:(CALayer *)layer{
}

displayLayer 永远不会被调用?

感谢和问候

4

1 回答 1

0

我修好了它:

记得设置

CABasicAnimation *anim = [CABasicAnimation animationWithKeyPath:@"indexKey"];

与以下内容相同:

+ (BOOL)needsDisplayForKey:(NSString *)key;

在 CALayer 上,您正在子类化

于 2012-10-11T09:30:52.203 回答