문제

UIImageView를 사용하여 표시하는 애니메이션이 있습니다.

imageView.animationImages = myImages;
imageView.animationDuration = 3;
[imageView startAnimating];

stopAnimating을 사용하여 중지할 수 있다는 것을 알고 있지만, 내가 원하는 것은 일시 중지할 수 있는 것입니다.그 이유는 중지를 호출하면 애니메이션 이미지가 표시되지 않는 반면, 버튼을 눌렀을 때 마지막으로 표시된 이미지가 계속 켜져 있기를 원하기 때문입니다.

지속 시간을 훨씬 더 큰 숫자로 설정하려고 시도했지만 이로 인해 모든 이미지도 사라집니다.이를 수행하는 정말 기본적인 방법이 있어야합니까?

도움이 되었습니까?

해결책 2

흠 ... 아무도 알지 못하는 것 같지 않기 때문에 불가능하다고 생각합니다.

나는 계속해서 내 자신을 썼다 UIView, a UIImageView subview, 그것은 an을 사용합니다 NSTimer 이미지간에 전환합니다. 이것의 장점은 여가 시간에 타이머를 일시 중지하고 재개 할 수 있다는 것입니다. 성능은 문제가되지 않는 것 같습니다.

다른 팁

이 코드는 애니메이션 프로세스에서 현재 위치에서 애니메이션 객체를 일시 중지합니다. 시간이나 진행과 같은 다른 변수를 녹음하는 경우, 필요한 모든 것을 다시 시작하는 것은 애니메이션을 다시 재개하는 것이 상당히 사소해야합니다.

UIView *viewBeingAnimated = //your view that is being animated
viewBeingAnimated.frame = [[viewBeingAnimated.layer presentationLayer] frame];
[viewBeingAnimated.layer removeAllAnimations];
//when user unpauses, create new animation from current position.

@oddmeter 약간 편집 :

    animatedView.animationImages = images; //images is your array
    [animatedView startAnimating];


    //Then when you need to pause;

[animatedView stopAnimating]; //Important!!
    animatedView.image = [images objectAtIndex: 0];

이렇게 하면 트릭을 수행할 수 있습니다. https://developer.apple.com/library/ios/#qa/qa2009/qa1673.html

기본적으로 일시 중지/재개하기 위해 수행해야 할 작업을 알려줍니다. CALayer 기반 애니메이션.

이용이 불편하시다면 CALayer 방법 UIImageView 제어된 애니메이션을 사용하면 언제든지 UIImage 배열 기반 애니메이션을 직접 만들어 보세요.필요한 코드는 매우 짧습니다. 여기에서 가져올 수 있습니다. http://rssv2.blogspot.com/2011/04/animating-series-of-images-with-calayer.html

또 다른 옵션은 이미지 속성과 animationImages 재산. 이렇게하면 정적 이미지가 표시됩니다 UIImageView 애니메이션이 중지되었습니다.

수업이 서브 클래스라고 가정합니다 UIImageView 그리고 NSMutableArray 이미지의 다음을 수행하십시오.

self.animationImages = images;
//yes, I'm skipping the step to check and make sure you have at least one
//element in your array
self.image = [images objectAtIndex: 0];

어쩌면 마지막 애니메이션 이미지의 스크린 샷을 찍어 표시 할 수 있습니까?

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top