Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Imitating screenshot flash animation on iOS

Tags:

ios

Im looking for a way to copy the "blink" animation, that is played when pressing home+lock.

Does anyone know if this animation is available somehow?

like image 847
Anders Avatar asked Sep 29 '13 16:09

Anders


2 Answers

On an iOS device you take a screenshot when you press home + lock and the screen flashes white. Do you mean this effect? If so, try this:

Add a UIView with a white background color to your view hierarchy such that it covers the whole screen. Then, start an animation that fades the opacity of this view to zero. On completion, remove the view from its superview:

[UIView animateWithDuration: 0.5 
                 animations: ^{
                               whiteView.alpha = 0.0;
                             }
                 completion: ^(BOOL finished) {
                               [whiteView removeFromSuperview];
                             }
];
like image 118
Theo Avatar answered Nov 04 '22 18:11

Theo


Try:

[UIView animateWithDuration:1 animations:^{
    self.view.backgroundColor = [UIColor blackColor];
    for (UIView *view2 in self.view.subviews) {
        view2.backgroundColor = [UIColor blackColor];
    }
}];
[UIView animateWithDuration:1 animations:^{
    self.view.backgroundColor = [UIColor whiteColor];
    for (UIView *view2 in self.view.subviews) {
        view2.backgroundColor = [UIColor whiteColor];
    }
}];
like image 22
Abdullah Shafique Avatar answered Nov 04 '22 18:11

Abdullah Shafique