我加入动画,一个UIView的层,什么情况是,当我第一次添加动画它正在经历的,但添加第二个动画删除第一位的,我怎么能平行添加两个cabasicanimation?请帮助我如何做到这一点。如何在单个uiview的图层上添加两个CABasicAnimations?
-(void)viewDidAppear:(BOOL)animated{
if (![ViewController weakDevice]) {
_imageView_BlurBackground.image = _blurBackgroundImage;
}else{
_imageView_BlurBackground.backgroundColor = [UIColor colorWithRed:96.0/255.0 green:96.0/255.0 blue:96.0/255.0 alpha:0.9];
}
CALayer *maskLayer = [CALayer layer];
// Mask image ends with 0.15 opacity on both sides. Set the background color of the layer
// to the same value so the layer can extend the mask image.
maskLayer.backgroundColor = [[UIColor colorWithRed:0.0f green:0.0f blue:0.0f alpha:0.40f] CGColor];
maskLayer.contents = (id)[[UIImage imageNamed:@"Mask3.png"] CGImage];
// Center the mask image on twice the width of the text layer, so it starts to the left
// of the text layer and moves to its right when we translate it by width.
maskLayer.contentsGravity = kCAGravityCenter;
maskLayer.frame = CGRectMake(0, -_creditListView.frame.size.height, _creditListView.frame.size.width, _creditListView.frame.size.height*2);
// Animate the mask layer's horizontal position
CABasicAnimation *maskAnim = [CABasicAnimation animationWithKeyPath:@"position.y"];
maskAnim.toValue = [NSNumber numberWithFloat:_creditListView.frame.size.height];
maskAnim.fromValue = [NSNumber numberWithFloat:0.0];
maskAnim.repeatCount = HUGE_VAL;
maskAnim.duration = 6.0f;
[maskLayer addAnimation:maskAnim forKey:@"slideAnim"];
_creditListView.layer.mask = maskLayer;
[_scrollView_CreditList setContentSize:CGSizeMake(_scrollView_CreditList.frame.size.width, _imageView_CreditList.frame.size.height+20)];
[self performSelectorOnMainThread:@selector(startRolling) withObject:nil waitUntilDone:YES];}
更新:
当第一个已到达其向下运动的约80%,其次是按照相同的图案随后闪烁白亮点的第二向下闪光应该开始。
我的看法层次是
CreditViewController--->
View---->
BlurBackground UIView
FirstAnimationView--->
ScrollView
ImageView
SecondAnimationView--->
ScrollView
ImageView
请提供您的建议,我应该如何实现这一点。
http://stackoverflow.com/questions/17764375/sequence-animation-using-caanimationgroup –
“但添加第二个动画删除第一个”是两个动画动画相同的关键路径? –
是的,他们使用相同的键路径。 –