UIView的支持CALayer不再重新启用Block中的隐式动画了吗?

时间:2017-01-13 02:47:09

标签: ios objective-c animation uiview calayer

根据official documentation

  

UIView类默认禁用图层动画,但在动画块内重新启用它们。

支持图层的隐式动画应该在UIView的动画块中重新启用。事实上,这个官方的片段

[UIView animateWithDuration:1.0 animations:^{ 

// Change the opacity implicitly.
myView.layer.opacity = 0.0;

// Change the position explicitly.
CABasicAnimation* theAnim = [CABasicAnimation animationWithKeyPath:@"position"];
theAnim.fromValue = [NSValue valueWithCGPoint:myView.layer.position];
theAnim.toValue = [NSValue valueWithCGPoint:myNewPosition];
theAnim.duration = 3.0;
[myView.layer addAnimation:theAnim forKey:@"AnimateFrame"];
}];

尝试触发背衬层上的隐式动画。此外,根据此question的答案,这是预期的行为。这blog's post也确认了

  

视图返回块外部的NSNull对象,并返回块内的CABasicAnimation

然而,目前这不是真的。从我的简单测试来看,UIView的动画块不会重新启用后面CALayer的隐式动画。另外,actionForLayer:forKey:现在返回动画块内外的NSNull。 这是否意味着官员已过时,这不再是预期的行为?

0 个答案:

没有答案