Fading CAShapeLayer path appearance - ios

I have an issue with showing a CAShapeLayer onto a CALayer.
Here is what I try to achieve:
I have an overlay over my view, I make a hole in the overlay so I can reveal what's behind. This works fine.
Now I want to be able to animate the creation of the hole. I'd like to have the hole part fading from the overlay color to transparent.
I already tried drawing another shape over the hole and make it disappear, it works, but this is not perfect as you can see in the last image (I can make it less visible, but still, it is not enough), and I don't think this is the correct way to do it.
If you have any idea or advice!
Thanks!

Related

Multi-colored Shadow Swift

In the iOS music app, I've noticed the shadow underneath album artwork changes based on the color of the artwork. This shadow can also be multi-colored based on how the color at the edge of the artwork changes.
Does anyone know how to recreate this effect programmatically?
Thanks to #Josh Homann for pointing me in the right direction, but the answer was actually much more complex.
The first (bottom) UIView in the hierarchy should have a plain white background and be pinned to the edges of the screen.
The next view should be a UIImageView with an alpha of 0.75.
Then you should add a UIVisualEffectView with the same dimensions as the first view.
Finally, add another UIImageView that is the same size as the first UIImageView.
Your IB hierarchy should look similar to this:
The final result is this:
Its not a shadow its a UIVisualEffectView with a blur. Add a second image view under your image view with a larger size and add a blurring visualEffectView to it.
Sorry to revive an old question, but this library nailed it: ShadowImageView.
It uses CIFilter which gives you more control over the blur effect and better results.

Creating transparent UIView with subtle blur effect

So I'm trying to replicate a UIView with a subtle transparent blur effect as shown in the wires above. I feel like I've tried everything...UIBlurEffectViews are too intense, I've tried a few 3rd party library's such as ILTranslucentView and FXBlurView that don't do the trick, I feel a bit hopeless. The idea is that the blurry transparent view will act as a slider view on top of another view. When the user pulls the slider view on top of it's parent view, the parent view will blur. If anyone could point me in the right direction I would really appreciate it.
To change the "subtlety" of the blur, you should change the blur radius, see this answer.

CGAffineTrasformRotation also rotates the coordinating system

I am rotating a UIView and then adding a new UIView to it. But it looks really weird.
Here is how it looks. The red box is the thing thats not as I expected.
I want the red box to be in the same direction as the blue box.
Im rotating the UIView like this:
[self setTransform:CGAffineTransformRotate(self.transform, DEGREES_TO_RADIANS(90))];
And then adding the red box as a UIView the normal way.
Im thinking that this is just the way transformations work and Im wondering if there is a way to fix it?
That's expected behavior if you're adding the red box after you perform the rotate. If you want the red box to have the same transformation as the blue one, then you'll need add the red box as its subview before applying the rotation transformation.

Cut out image of UIView to reveal background tint

I currently have a main UIView that I have subclassed and set a custom background colour from a UIImage.
I also have a .png with a transparent background - lets call it myImage.png.
I want to be able to add the myImage.png to the main view so that I am able to animate the non-transparent portion of my UIImage. I assume that this could be achieved with the use of layers and image masking but I would really appreciate an example to get me started.
EDIT
To clarify, I am interested in knowing how I can use core graphics to cut out the myImage.png and reveal a tint colour. I can then animate this tint colour to give a flashing effect. I am able to animate the image without a problem, so I need a solution to the problem of 'cutting out' the image and revealing a background tint that I my animate in and out.
I am using iOS6
Thanks in advance.
You can play around with CAGradientLayer, CATransformLayer, CAReplicatorLayer.
As I understand your question you have a .png with transparent background and you want to animate the non-transparent part of this .png (myImage.png) you want to add myImage.png to your main view with an animation. Take a look of this apple documentation link of Core Animation
https://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/CoreAnimation_guide/CreatingBasicAnimations/CreatingBasicAnimations.html
It will help you with what you want

IOS - How to draw a border and a shadow that rotates with view but doesn't scale with it

I am developing an ios app.
In my app I have got a view, the view is has got a border and a shadow.
The view can be scaled and rotated.
When a user scaled my view it causes my border and shadow to scale as well.
I don't want my shadow or border to scale at all.
On the other hand I do want my shadow and border to rotate when I rotate the view.
Is there any built in mechanism to prevent border \ shadow scale?
Thank you
As far as I know there isn't such a built in mechanism.
The only way I see for you to solve your problem is to simply use two different views, with different management in case of rotation.
Have one view as a sort of background and add your border and shadow to it, and then place the content on top of it (or in it, depends on your case).

Resources