similaires à la réponse fournie par Max, mais en utilisant UIView animateWithDuration à la place
- (void)flashScreen {
// Make a white view for the flash
UIView *whiteView = [[UIView alloc] initWithFrame:self.view.frame];
whiteView.backgroundColor = [UIColor whiteColor];
whiteView.alpha = 1.0; // Optional, default is 1.0
// Add the view
[self.view addSubview:whiteView];
// Animate the flash
[UIView animateWithDuration:1.0
delay:0.0
options:UIViewAnimationOptionCurveEaseOut // Seems to give a good effect. Other options exist
animations:^{
// Animate alpha
whiteView.alpha = 0.0;
}
completion:^(BOOL finished) {
// Remove the view when the animation is done
[whiteView removeFromSuperview];
}];
}
Il existe différentes versions de animateW ithDuration, vous pouvez par exemple également utiliser cette version plus courte, si vous n'avez pas besoin d'un délai et que vous êtes d'accord avec les options d'animation par défaut.
[UIView animateWithDuration:1.0
animations:^{
// Animate alpha
whiteView.alpha = 0.0;
}
completion:^(BOOL finished) {
// Remove the view when the animation is done
[whiteView removeFromSuperview];
}];
N'oubliez pas de tout sortir lorsque vous avez terminé :) –
C'est une réponse étonnamment rapide et correcte. Merci beaucoup Max !! – Patryk