2013-06-26 3 views
2

"뷰의 복사본을 만들고이 복사본을 점에서 다른 점으로 이동하면서 불투명도가 완전히 사라질 때까지 줄이는"애니메이션을 만들고 싶습니다.중복 된 레이어로 이동

은 내가 CABasicAnimation 그래서 내가 그 같은 노력을 통해 내가 그것을 할 필요가 가정 :

CGPoint point = CGPointMake(200, 0); 

    // copy layer 
    CALayer *layer = [[CALayer alloc] initWithLayer:self.animatedView.layer]; 
    [self.animatedView.layer addSublayer:layer]; 

    CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"position"]; 
    animation.fromValue = [layer valueForKey:@"position"]; 
    animation.toValue = [NSValue valueWithCGPoint:point]; 
    animation.duration = 2.0f; 

    CABasicAnimation *oanimation = [CABasicAnimation animationWithKeyPath:@"opacity"]; 
    oanimation.fromValue = @1; 
    oanimation.toValue = @0; 
    oanimation.duration = 1.0f; 

    // move copy layer 
    [layer addAnimation:animation forKey:@"position"]; 
    [layer addAnimation:oanimation forKey:@"opacity"]; 

를하지만의 속삭임을 추가하고 내가 그것을 문서에 대한 정상적인 상황이라고 생각 :

이 초기화 presentationLayer 메서드에 대해 예제의 경우 레이어의 섀도 복사본을 만드는 데 사용됩니다. 다른 상황에서이 메서드를 사용하면 정의되지 않은 동작이 발생합니다. 예를 들어, 이 방법을 사용하여 기존 레이어의 콘텐츠로 새 레이어를 초기화하지 마십시오.

누군가 이미 이전에 이런 종류의 애니메이션을 사용 했습니까?

당신의 도움을 위해 Thx.

+0

왜 사본을 재생? 그리고 왜 레이어? 원래보기를 이동하고 사라지지 않는 이유는 무엇입니까? – Wain

+0

이것은 내가하고 싶은 것이 아니기 때문에. 난 왼쪽 컨트롤러에서 왼쪽 컨트롤러에서 남아있는 동안 왼쪽에서 오른쪽으로 움직임을 가짜로 효과를 원한다 그래서 오른쪽 컨트롤러 (분할 화면)에보기를 복사 해요 – Yaman

+1

좋아, 그래서 당신이 복사 할 수 있지만 여전히 할 수있는 뷰 수준에서. 'UIView'는'NSCoding'을 따르므로 복사 할 수 있습니다. – Wain

답변

0
UIGraphicsBeginImageContext(theView.frame.size); 
CGContextRef context = UIGraphicsGetCurrentContext(); 
[theView.layer renderInContext:context]; 
UIImage *screenShot = UIGraphicsGetImageFromCurrentImageContext(); 
UIGraphicsEndImageContext(); 

UIImageView *imgView = [[UIImageView alloc] initWithImage:screenShot]; 
imgView.frame = theView.frame; 
[self.view addSubview:imgView]; 

는 'imgView':