核心animation隐式animation不会为新添加的子层触发
不知道为什么这不起作用。 我不能为新添加的子层做隐式animation,除非有人甚至像触发button或从另一个方法中调用它。 即使我认为我应该这样下面这个不animation。 它只是显示图层的“之后”状态。
CAGradientLayer *newBar = [CAGradientLayer layer]; CGFloat barHeight = ((pair.amount.floatValue/self.model.maxModelValue.floatValue)*maxBarHeight); newBar.bounds=R(0,0,self.barWidth,0); newBar.anchorPoint=P(0, 1); newBar.position=P((i*barSpacing), self.insideLayer.bounds.size.height); newBar.backgroundColor=self.lowerColor.CGColor; newBar.colors=[NSArray arrayWithObjects:(id)self.upperColor.CGColor, self.lowerColor.CGColor, nil]; newBar.cornerRadius=self.cornerRadius; newBar.opacity=1.0; [self.insideLayer addSublayer:newBar]; //animation line: newBar.opacity=0.5;
如果图层不是表示层层次结构的一部分,则Core Animation不会创build隐式animation。
尝试这个:
... [self.insideLayer addSublayer:newBar]; // Tell Core Animation to update the presentation layer hierarchy: [CATransaction flush]; // animation line: newBar.opacity = 0.5;
- iOS – CALayer和手势/滑动识别器
- 我如何能UIImageView在UICollectionViewCell?
- CALayer.contents在AVMutableComposition中不能正确渲染
- 我如何可以自定义borderWidth的所有UITextField外观?
- 通过在后台线程 – iPhone上渲染UIWebView来创buildUIImage
- 在Swift中animation自定义UIView属性
- CABasicAnimation – 两个angular度之间的animation
- 如何检测由CATransaction触发的animation的完成?
- Swift:如何启用CALayer的捏缩放?