다음 코드를 사용하여 원을 애니메이션화합니다. 끊임없이 깜박이고, 애니메이션 재시작을 지연시키고 싶습니다. 5 초를 말합니다. 어떻게해야합니까?애니메이션 이폰에 지연 넣기
-(void)start
{
[self removeExistingAnimation];
//create the image
UIImage* img = [UIImage imageNamed:@"redCircle.png"];
imageView = [[UIImageView alloc] initWithImage:img];
imageView.frame = CGRectMake(0, 0, 0, 0);
[self addSubview:imageView];
//opacity animation setup
CABasicAnimation *opacityAnimation;
opacityAnimation=[CABasicAnimation animationWithKeyPath:@"opacity"];
opacityAnimation.duration = ANIMATION_DURATION;
opacityAnimation.repeatCount = ANIMATION_REPEAT;
//theAnimation.autoreverses=YES;
opacityAnimation.fromValue = [NSNumber numberWithFloat:0.6];
opacityAnimation.toValue = [NSNumber numberWithFloat:0.025];
//resize animation setup
CABasicAnimation *transformAnimation;
transformAnimation = [CABasicAnimation animationWithKeyPath:@"transform.scale"];
transformAnimation.duration = ANIMATION_DURATION;
transformAnimation.repeatCount = ANIMATION_REPEAT;
//transformAnimation.autoreverses=YES;
transformAnimation.fromValue = [NSNumber numberWithFloat:MIN_RATIO];
transformAnimation.toValue = [NSNumber numberWithFloat:MAX_RATIO];
//group the two animation
CAAnimationGroup *group = [CAAnimationGroup animation];
group.repeatCount = ANIMATION_REPEAT;
[group setAnimations:[NSArray arrayWithObjects:opacityAnimation, transformAnimation, nil]];
group.duration = ANIMATION_DURATION;
//apply the grouped animaton
[imageView.layer addAnimation:group forKey:@"groupAnimation"];
}
작동하지 않습니다. 직접 사용해보세요 –
@MuhammadUmar이 프레임 워크에서 사용중인 프레임 워크는 무엇입니까? – Dilip
QuartzCore. opacityAnimation.duration = ANIMATION_DURATION을 제거하면 작동합니다. 그리고 다른 애니메이션 지속 시간이지만 애니메이션이 멈 추면 여전히 하나의 버그가 있습니다. imageView는 여전히 자체에 추가되고 큰 Red Circle을 볼 수 있습니다. 이 원을 제거하고 싶습니다. atEndAnimation 호출 함수 removeExistingAnimation –