Draw shadow on iOS - CALayer vs UIImage - ios

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.

Related

How to make viewport backgroundcolor clear in OpenGLES 2.0

I wanna make viewport backgroundcolor clear,transparent.
But
glClearColor(0,0,0,0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
do not work,it is just all black.
I am using OpenGLES2.0 and iOS platform。
glClearColor(backgroundColorRed, backgroundColorGreen, backgroundColorBlue, backgroundColorAlpha);
glClear(GL_COLOR_BUFFER_BIT);
So how to do it if I want to make viewport backgroundcolor transparent?
I think the glview cannot be transparent.
Here is an example, you have a UIImageView which contain a background image.
You want to add a transparent glview upon the UIImageView, make it like watermark.
Unfortunately, the glview cannot be transparent, so the Alternative way is:
Make two gl_textures, one texture use to draw your background image. Another one draw you're watermark.
The gl_texture can be transparent.

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: 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.

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.

How do I draw a monochrome PDF with a tint color and opacity on iOS?

I need to draw a monochrome PDF in an iOS app, but replacing the color in the PDF with another color, and applying an opacity value. I'd like to show the result in a UIImageView or UIView.
I can draw the PDF using Quartz functions, but it is drawn black (the color of the original PDF). What would be the best way to do this?
I was able to accomplish this in the following way:
Draw the PDF into a transparent UIImage.
Set that image as the contents of a new CALayer, and set the size of the layer to be the same as the image.
Set the layer as the mask of a UIView's layer.
Set the background color (including opacity) of the view as desired.
It is not possible to implement this using the standard iOS PDF APIs.

Resources