I have an UIImageView with an Animation and, in the UIView, I apply a fadeIn effect, but I need to apply fade out when the UIImageView, which is animated, when is touched.
This is what I make to fade in.
UIView.animateWithDuration(0.5, delay: delay,
options: UIViewAnimationOptions.CurveEaseOut, animations: {
uiImageView.alpha = 1.0
}
A fade-in effect begins with a solid color (Movie Maker supports both black and white) and then fades into your video. A fade-out effect begins with the video and then fades into the solid color, again either black or white.
In case of a video processor, the fade out effect refers to the transition form, where the video content of a certain video window smoothly dissolves to the background. This operation must be performed parallel over several monitor screens in real time.
This is what I would do based on my research: (Supposing you're using storyboard)
Go to your UIImageView, and under the Attributes, check the "User Interaction Enabled" checkbox.
Drag a TapGestureRecognizer on top of the image view.
Control click on the Tap Gesture and drag to make a action on your ViewControler.swift.
Add the following code inside:
UIView.animate(withDuration: 0.5, delay: 0.5, options: .curveEaseOut, animations: {
self.uiImageView.alpha = 0.0
}, completion: nil)
Then you're done!
Starting from iOS 10 Apple launched new iOS Animations SDK that is much more powerful, especially concerning timings functions and interactivity.
Fade out code with this approach will:
UIViewPropertyAnimator(duration: 0.5, curve: .easeOut, animations: {
self.uiImageView.alpha = 0.0
}).startAnimation()
To get more details about the Property Animator, take a look at iOS 10 Animations demo.
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