iOS Glint Effect Text - ios

How would one implement a text glint effect similar to the Slide to Unlock image, or in the Paypal app?
Is it possible to have transparent text and animate some sort of white shape moving behind it?

Please refer to MTAnimatedLabel which does the exact same thing.
He uses a CATextLayer to mask a CAGradientLayer and then he animates the gradient layer for the required effect.
You can find the usage details in the link. You can even change the tint color.

Related

How do you create a 'blurred text' image effect in iOS?

I want to create a text shaped blur effect to an image as shown below:
Another example:
I have found an answer on blurring a UILabel answer: How to blur UILabel text.
But the effect is not correct.
So, How can I create a blurred text image effect that I can render into an image as a watermark in Swift?
Somebody help me! Thanks very much!
By the way, the answers about UIVisualEffectView is not correct.
The effect using UIVisualEffectView is like:
Besides, I also want to apply this kind of blur effect into photo's watermark.
So, any help?
You're going to need a two stage approach to get the desired effect:
Generate a black and white image of the text (black background, white text). The standard string in Swift has a Draw method. There's another Answer that has more detail on this.
Pass this 'text' image and your source image into the CIMaskedVariableBlur filter from CoreImage.
Basically, your 'text' image will act as the mask for the blur filter. Where the mask is lighter, the blur is stronger, and where the mask is black, no blur is applied.

UIImage with Gradient iOS

Is it possible apply a gradient like this for iOS?
The gradient is applied to the image and it should lose focus. I can get the result for the background with CAGradientLayer but the image always has the same focus.
Maybe you can find useful applying some technics for image resizing in order to achieve the focus you want.
http://nshipster.com/image-resizing/

I want to draw custom shape like apple shape on UIView

I am trying to make Apple kind of shape for progressHUD. I have option to use .png Image but I cant because I have to fill the apple Shape with different colour depends of percentage status.. I am using UIView to draw this shape...
I want suggestion how to draw apple kind of shape easily?
And How we can fill half colour with different colour?
I have option to use .png Image but I cant
Yes, you can. — Get hold of some apple-shaped artwork. Use it as a mask - it punches a hole in a view. Now put another view behind it, with a color. Now the apple appears to be that color, because that color is being seen through the apple-shaped hole. Now put another view behind it, with a different color, and move it up or across the right amount so as to divide what's seen through the apple into two colors.
Using that approach, it took me about 30 seconds to create this result (using your apple-shaped artwork as a .png image!):

iOS7 "Slide to unlock" animation on a UILabel

How to make an animation similar to "Slide to unlock" text on a UILabel? (The text gradient is animated left->right) and then the text color adapts to the background.
I think the key to performing this effect is CALayer mask. You can attach a second CALayer to any existing layer as its mask. Then:
The [mask] layer’s alpha channel determines how much of the [parent] layer’s content
and background shows through. Fully or partially opaque pixels allow
the underlying content to show through but fully transparent pixels
block that content.
So the text is going to be the mask and the moving colour is going to be the parent.
The easiest way to deal with the text will be to use a CATextLayer. The easiest way to make the colour gradient will be CAGradientLayer.
To animate the gradient you can use Core Animation, since all properties are animatable. I guess locations is likely to be the best way to achieve the sliding animation.
For convenience you'll probably want to wrap all of that up into a UIView, but you can add layers directly if you prefer.

drawRect: How do I do an "inverted clip"

I am creating an iOS user interface to allow a user to pick a rectangle within an existing image, dragging the corners of that rectangle to the desired size. I now have four custom UIButtons (30% alpha) and a custom view (also with 30% alpha) that draws the dashed lines between the four corner buttons.
To "improve" the interface, I would like my drawRect code to make the cropped portion of the image appear "normal" while everything outside the cropped region is washed out (filled with white color, which will give me the correct effect since the UIView is set to 30% alpha).
The obvious algorithm would be:
Fill the entire image with [UIColor whiteColor] fill
Draw the four dashed lines with a [UIColor clearColor] fill
When I do this, the clear fill isn't showing up. I believe this is because the "fill" of the clear color in step #2 isn't being seen because the pixels were already set to white in step #1. Perhaps there's a blend mode that will allow me to see the transparency of the second rectangle? I'm not sure about the various blend modes.
My second attempt, which works, does the following:
Draw the four dashed lines with [UIColor clearColor] fill
Draw four additional rectangles with [UIColor whiteColor] fill, each representing the portions to the left, right, above, and below the cropped region.
As I mention, this method works, but seems to me there should be a simpler way instead of me having to calculate these four additional rectangles each and every time.
There is a similar question on SO Create layer mask with custom-shaped hole that uses CALayer and masks, but this seems to be overkill for what I need.
Does anybody have any suggestions on how to improve this?
You can set the blend mode to kCGBlendModeCopy and use clearColor to reset a pixel's alpha to zero. You can presumably also use kCGBlendModeClear but I haven't tested that.
You can also set the clipping path to just contain the pixels you want cleared and call CGContextClearRect(gc, CGRectInfinite).
If you want to use a clipping mask with a hole in it, you can do so without using a CALayer, and you can build it a little more simply than in the answer you linked, by using the even-odd rule and CGRectInfinite:
CGContextSaveGState(GC); {
CGContextBeginPath(gc);
CGContextAddRect(gc, myRect); // or whatever simple path you want here
CGContextAddRect(gc, CGRectInfinite);
CGContextEOClip(gc);
// drawing code here is clipped to the exterior of myRect
} CGContextRestoreGState(gc);

Resources