3
이미지 시퀀스에 애니메이션을 적용하려고하는데이 작업은 간단한 UIImageView 애니메이션으로 쉽게 수행 할 수 있습니다. 그러나 애니메이션이 끝날 때이를 감지하여 사용자가 다른 작업을 수행하도록 허용 할 수 있기를 원합니다. 그래서 CAKeyframeAnimation을 사용하여 작업하려고했습니다. 다음 코드를 실행했을 때 프로그램이 다운되었습니다. 누군가 내가 잘못한 것을 말해 줄 수 있습니까? 당신이 말한대로이 다음 사실, 간단한 UIView의 애니메이션으로 수행 할 수있는 경우CAKeyframeAnimation을 사용하여 이미지 시퀀스 애니메이션하기
CALayer *myLayer = [[CALayer alloc]init];
[myLayer setBounds:CGRectMake(0, 0, 100, 100)];
[myLayer setPosition:CGPointMake(160.0, 100.0)];
myLayer.backgroundColor = [[UIColor colorWithRed:4 green:0 blue:0 alpha:1] CGColor];
[self.window.layer addSublayer:myLayer];
CAKeyframeAnimation *anim;
NSArray *images =[NSArray arrayWithObjects:[UIImage imageNamed:@"img1.png"],
[UIImage imageNamed:@"img2.png"],nil];
anim = [CAKeyframeAnimation animation];
[anim setKeyPath:@"contents"];
[anim setValues:images];
[anim setCalculationMode:@"discrete"];
[anim setRepeatCount:3];
[anim setDuration:1.0];
[myLayer addAnimation:anim forKey:nil];
'UIImage'에 값을 설정하고'contents' 속성에 필요한 CGImageRef가 아닌 값으로 설정하면 충돌이 발생할 수 있습니다. –