iOS: Apply rotating UIImage as alpha mask to another UIImageView - ios

I have a UIImageView. I'd like to use a specific UIImage as an alpha mask to this UIImageView so that the UIImageView's image takes on the alpha component of the UIImage. The tricky part is that the UIImage should be rotating so that the alpha component of the UIImageView's image is animating.
I've never done this sort of thing. Could someone help me get started?
Thank you.

You should be able to do this by installing your mask image into a CALayer and then installing that layer as the mask on your image view's layer.
Finally you'd create a CABasicAnimation that would animate the rotation.z of the mask layer's transform.
I don't know for absolutely certain that rotating a mask layer animates the masking action, but I'm pretty sure it would work.

Related

SWIFT - CALayer between PNG and background image

I have seen many stackoverflow posts or tutorials on how make a mask with an image and a rectangle or a circle, but it is possible to make a mask between a png file with transparency and a background image.
In the photoshop screenshot I use the wolf png image as a mask for the background.
Any approach for this with CALayer or other in SWIFT ?
Thank you very much.
UIView as of iOS 8 has a mask property which you can set to any view with an alpha channel, including a UIImageView that has your image in it.
This is just a wrapper arround CALayer's mask property which works similarly. Set your image to the content property of your masking layer and set the masking layer as the mask for your background image layer.

ios - How to do the clipping mask effect using the two images

Am having the mask image and the normal image i want to do the exact clipping mask effect and want to set that image to the UIImageView.
In this PIP Camera app they did this
https://itunes.apple.com/in/app/hua-zhong-hua-xiang-ji-nice/id521922264?mt=8
And i tried this
How to Mask an UIImageView
exactly what they suggest but no luck
Could anyone here give an idea of how we do that?

How Can I Mask a UIView and Not just the UIImage

I am trying to mask a complete UIView is this possible? The view I am trying to mask has a blur effect layered on top of it. I am to successfully mask the image under the UIView but not the entire View itself. Basically I need to be able to mask a UIView.

Draw shadow on iOS - CALayer vs UIImage

What is the best way (in performance and code maintenance) to draw a shadow?
Have it in the image (png) you want the shadow to be in.
Draw with CALayer properties
Thanks.

CSS Masking in iOS

I have an image in my iOS app. I want to use css masking technique to achieve the same image but with colors. The 1st image is the original image and the 2nd image is the output image that is required. How can i achieve it in iOS :
The drawing system on iOS is called Quartz 2D. Here's the documentation:
https://developer.apple.com/library/ios/documentation/graphicsimaging/conceptual/drawingwithquartz2d/dq_overview/dq_overview.html
You will be able to use the shape of your image as a clipping path and then draw a gradient.
Alternatively, a simpler way is to draw a simple gradient with a CAGradientLayer and then mask the layer; see the documentation on CALayer and CAGradientLayer.

Resources