Is the flash screen white at the time of capturing the camera?

I want the flash (and then disappear) of the screen right at the time of capturing the camera, to give the user an indication that the photo was taken (in addition to just the auditory key).

Where will this animation be placed? Also, how will it be implemented so that I can control the duration of the fadeout?

Note. I created a custom overlay for my specific camera selection.

All that indicates that a photograph was taken is what I am looking for.

+6
source share
1 answer

I'm not sure where you will place the animation, because I don’t know exactly how you shoot the image (maybe you can post the code), but the animation code for the flash screen is white:

//Header (.h) file @property (nonatomic, strong) UIView *whiteScreen; //Implementation (.m) file @synthesize whiteScreen; - (void)viewDidLoad { self.whiteScreen = [[UIView alloc] initWithFrame:self.view.frame]; self.whiteScreen.layer.opacity = 0.0f; self.whiteScreen.layer.backgroundColor = [[UIColor whiteColor] CGColor]; [self.view addSubview:self.whiteScreen]; } -(void)flashScreen { CAKeyframeAnimation *opacityAnimation = [CAKeyframeAnimation animationWithKeyPath:@"opacity"]; NSArray *animationValues = @[ @0.8f, @0.0f ]; NSArray *animationTimes = @[ @0.3f, @1.0f ]; id timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear]; NSArray *animationTimingFunctions = @[ timingFunction, timingFunction ]; [opacityAnimation setValues:animationValues]; [opacityAnimation setKeyTimes:animationTimes]; [opacityAnimation setTimingFunctions:animationTimingFunctions]; opacityAnimation.fillMode = kCAFillModeForwards; opacityAnimation.removedOnCompletion = YES; opacityAnimation.duration = 0.4; [self.whiteScreen.layer addAnimation:opacityAnimation forKey:@"animation"]; } 

You also asked how to control the length of the attenuation. You can do this by setting the values ​​in the animationTimes array. If you're not familiar with how CAKeyframeAnimations works, then here's a quick break. The total duration of the animation is controlled by opacityAnimation.duration = 0.4 . This makes the animation 0.4 seconds. Now about what animationTimes does. Each value in the array represents a number from 0.0 to 1.0 and corresponds to an element of the array 'animationValues'. The value in the times array determines the duration of the corresponding keyframe value as a fraction of the total animation duration.

For example, in the animation above, the time array contains values ​​of 0.3 and 1.0, which correspond to values ​​of 0.8 and 0.0. The total duration is 0.4, so this means that the appearance of a white screen, which has an opacity of initially at 0.0, takes

 0.4 * 0.3 = 0.12 seconds. 

to increase the opacity to 0.8. The second value, 0.0, makes the layer transparent again. It takes the rest of the time (0.4-0.12 = 0.28 seconds).

+9
source

Source: https://habr.com/ru/post/921729/


All Articles