Hi.
I'm trying to animate the sublayer of a UIView's layer with the following code:
I don't understand why my sublayer doesn't animate since the code
does animate the view's main layer.
Thanks.
I'm trying to animate the sublayer of a UIView's layer with the following code:
Code:
CALayer *sublayer = [[CALayer alloc] init];
[sublayer setFrame:myRect]; // myRect is a portion of the view's frame rectangle
[self.layer addSublayer:sublayer];
CABasicAnimation *anim = [CABasicAnimation animationWithKeyPath:@"opacity"];
anim.duration = 1.0f;
anim.fromValue = [NSNumber numberWithFloat:1];
anim.toValue = [NSNumber numberWithFloat:.5];
anim.delegate = self;
[sublayer addAnimation:anim forKey:@"animateOpacity"];
I don't understand why my sublayer doesn't animate since the code
Code:
[self.layer addAnimation:anim forKey:@"animateOpacity"];
Thanks.