Аналогично ответу от Макса, но вместо него используется UIView animateWithDuration
- (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];
}];
}
Существуют разные версии animateWithDuration, например, вы также можете использовать эту более короткую версию, если вам не нужна задержка и вы согласны с параметрами анимации по умолчанию.
[UIView animateWithDuration:1.0
animations:^{
// Animate alpha
whiteView.alpha = 0.0;
}
completion:^(BOOL finished) {
// Remove the view when the animation is done
[whiteView removeFromSuperview];
}];