How Can I Mask a UIView and Not just the UIImage - ios

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.

Related

How to ensure a UIView with a transform fills a CGRect?

I have a view UIView that by default has a UIImageView (the blue square in the included image) that is centered in this main view (the gray square in the included image). The main view has an added CALayer that serves as a border (window or mask — the yellow rectangle in included image) through which the image can be seen. The user uses gesture recognizers to pan (translate), pinch (scale), and rotate the image view's transform, but I'd like to give them the option of transforming the image so it completely fills the yellow border (all four corners), much the same way the iOS crop tool does (see attached gif). I've tried to figure out how I can calculate the correct scale factor, but now I'm wondering — is there some simple formula or function that can help me solve this problem?

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.

Draw custom layout for iOS

I have this custom layout as in this picture :
The four rectangles are UIViews with border lines over a CALayer. In the middle of this rectangles are another UIView as a circle. I would like to draw the border line of the circle where the rectangles are open. The difficulty is that the rectangles are autoresizing and the UIView in the middle. How can I make that ?

iOS: Apply rotating UIImage as alpha mask to another UIImageView

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.

Apply a mask to a UIView to simulate a glass shimmer

My base image is a complex shape with multiple colors and an alpha background.
My shimmer effect is a white slanted gradient with an alpha background.
My goal is to animate the shimmer image over top of the base image, but make the alpha values of of the shimmer match those of the base image.
I've only used layer masks to hide areas based on the color, not to both show AND hide parts of an image. Will I need to create multiple masks to achieve this? A white version of my base image that will show through the masked shimmer image, all on top of my colored base image?
Since your shimmer effect is created by moving a single image/layer over a base image, you only need one mask in the shape of the non-alpha values in your base image. You will likely need to use a container view for your shimmer image view/layer that you overlay onto of the base image, then set the image mask on the container.

Resources