0
사용자가 화면에 닿기 전까지는 두 개의 다른 위치로 페이드 인 및 페이드 아웃되는 작은 파란색 원이 있습니다. 그런 다음 원이있는 위치에 서클이 희미 해지기를 원합니다. 무슨 일이 일어나고 무엇왜 내 애니메이션이 작동하지 않습니까?
- (void)fadePowerUpOut {
[UIView animateWithDuration:.5 delay:2 options:UIViewAnimationOptionCurveLinear animations:^{//the power up will stay in its position until after 2 seconds it will fade out which is because of the delay
self.powerUp.alpha=0;
} completion:^(BOOL finished) {
if (finished) {//I put if finished here because i don't want this method to be ran if the user touches the screen within the 2 second delay
if (self.powerUp.frame.origin.x==self.rectPowerUp.origin.x) {//if its in the first location go to the second
self.powerUp.frame=self.rectPowerUp2;
}else{//if its in the second location go to the first
self.powerUp.frame=self.rectPowerUp;
}
[self fadePowerUpIn];
}
}];
}
- (void)fadePowerUpIn {
[UIView animateWithDuration:.5 delay:0 options:UIViewAnimationOptionCurveLinear animations:^{
self.powerUp.alpha=1;
} completion:^(BOOL finished) {
if (finished) {
[self FadePowerUpOut];
}
}];
}
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
[UIView animateWithDuration:.5 delay:0 options:UIViewAnimationCurveLinear|UIViewAnimationOptionBeginFromCurrentState animations:^(){ self.powerUp.alpha=0;} completion:^(BOOL completion){
}];
}
는 사용자가 원 그냥 페이드 아웃하지 않는 화면을 터치 할 때입니다,하지만 2 초 (나는 fadePowerUpOut 방법에 넣어 지연) 후 페이드 아웃.
두 경우 모두'[self FadePowerUpOut];을 호출 할 때 지연을 0으로 설정하지 않으려 고합니다. [self performSelector : @selector (FadePowerUpOut) withObject : nil afterDelay : 2];로 시도해보십시오. – iDev