2014-04-25 7 views
0

uiview의 레이어에 애니메이션을 추가하고 있는데, 첫 번째 애니메이션을 추가 할 때 첫 번째 애니메이션을 추가 할 때 두 번째 애니메이션을 추가하면 첫 번째 애니메이션이 제거되므로 어떻게 두 개의 cabasicanimation을 병렬로 추가 할 수 있습니까? 그렇게하는 법을 도와주세요. 단일 Uiview의 레이어에 두 개의 CABasicAnimations를 추가하는 방법은 무엇입니까?

enter image description here

-(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 

나에게 당신의 제안을 제공하십시오입니다.

+0

http://stackoverflow.com/questions/17764375/sequence-animation-using-caanimationgroup –

+0

"두 번째 애니메이션을 추가하면 첫 번째 애니메이션이 제거됨"두 애니메이션이 동일한 키 경로를 애니메이션으로 나타 납니까? –

+0

예 그들은 동일한 키 경로를 사용합니다. –

답변

2

모든 애니메이션을 함께 그룹화 한 다음보기에 애니메이션 그룹 만 적용하려면 CAAnimationGroup을 사용해야합니다.

이 기술을 사용하면 서로 다른 키 패스에서 동시에 실행되는 여러 애니메이션을 가질 수 있으며 적절한 키 필드에서 여러 애니메이션을 순서대로 실행할 수 있습니다 (적절한 타이밍 세부 정보 설정).

애니메이션 그룹이나 다른 방법을 사용하여 동일한 키 패스에서 동시에 여러 애니메이션을 실행할 수 없습니다.

+0

내 문제를 해결할 수 있다고 생각하지 않습니다. 왜냐하면 두 번째 애니메이션이 시작될 때 그룹에서 첫 번째 애니메이션이 중지되기 때문입니다. 하지만 두 애니메이션이 함께 작동해야합니다. –

+0

각 애니메이션은 다른 자산 권리를위한 것입니까? – Wain

+0

사실 나는 position.y ketPath를 사용하여 아래로 굴러 다니는 애니메이션을 가지고 있는데, 처음 애니메이션이 화면 높이의 90 %를 완성 할 때 다른 애니메이션이 맨 처음부터 영향을 미치지 않으면 서 튀어 나오길 원합니다. 같은 keyPath를 사용하여 두 번째 애니메이션을 추가하면 첫 번째 애니메이션이 지워집니다. –