I'm very new to Objective-C and have just made my first app from scratch. It's a spelling app and I would like to display same white flash that is displayed on the screen when you take a screenshot if the user enters the wrong letter. How would I do that?
// Create a empty view with the color white.
UIView *flashView = [[UIView alloc] initWithFrame:window.bounds];
flashView.backgroundColor = [UIColor whiteColor];
flashView.alpha = 1.0;
// Add the flash view to the window
[window addSubview:flashView];
// Fade it out and remove after animation.
[UIView animateWithDuration:0.05 animations:^{ flashView.alpha = 0.0; } completion:^(BOOL finished) { [flashView removeFromSuperview]; } ];
Add a fullscreen white UIView
on top of everything and animate its alpha.
// Create a fullscreen, empty, white view and add it to the window.
UIWindow *window = [[UIApplication sharedApplication] keyWindow];
UIView *flashView = [[UIView alloc] initWithFrame:window.bounds];
flashView.backgroundColor = [UIColor whiteColor];
flashView.alpha = 1.0f;
[window addSubview:flashView];
// Fade it out and remove after animation.
[UIView animateWithDuration:0.05f animations:^{
flashView.alpha = 0.0f;
} completion:^(BOOL finished) {
[flashView removeFromSuperview];
}];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With