1
CAMediaTiming
协议定义属性timeOffset
,该属性应该设置动画或动画图层的附加时间偏移。通过设置layer.speed = 0
,可以通过将layer.timeOffset
设置为给定值来手动控制动画定时。无法控制UITableViewCell的子图层的动画定时
,我设法做一个常规视图,但是当我尝试这样做(规定时间内层的偏移量)当层的UITableViewCell的层的后裔,它没有任何效果。
下面是一个简短的代码片段,您可以看到我正在尝试实现的目标以及无法实现的目标。
-(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
[tableView deselectRowAtIndexPath:indexPath animated:NO];
CALayer *layer = [CALayer layer];
layer.frame = CGRectMake(0, 0, 80, 80);
layer.backgroundColor = [UIColor redColor].CGColor;
layer.opacity = .1f;
[cell.contentView.layer addSublayer:layer];
CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"opacity"];
animation.toValue = (id) [NSNumber numberWithFloat:1.f];
animation.duration = 1.f;
[layer addAnimation:animation forKey:nil];
layer.timeOffset = 0.7f;
layer.speed = 0.f;
}
它只是timeOffset不起作用,或者您能告诉我们更多关于正在发生的事情吗? –
是的 - 在'CAMediaTiming'协议中定义的所有属性都可以工作,但'timeOffset' – wczekalski