Cut out image of UIView to reveal background tint - ios

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

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.

Desaturate a live UIView layer (not a UIImageView)

I'm wondering what would be the best way to desaturate a UIView—particularly, a UISliderView with custom appearance applied to it. In iOS 7, the standard controls fade out their tint colors when another view appears over them (for example, a share sheet or UIAlertView), but since mine is built from UIImages, the tint property doesn't apply to it, and they remain saturated.
Is there a good, easy way to desaturate this, short of re-applying a new UIAppearance for it? (If I were to go that route, would I even be able to animate the transition from colored images to greyscale ones?)
Thanks in advance!

Add color to white bounce area of UIWebView

I'm trying to add a beige color to the bounce white space area that appears when dragging this WebView off screen. I've tried setting the WebView and WebView.ScrollView background colors manually and also setting them to transparent with opaque set to false having the ViewController's view background color set to beige - no luck. I also read in some of the objective-C iOS threads that adding a SubView with the background color I want to the WebView would do the trick, but could not get this to work in Mono.
The background of the Web content has been set in the HTML code of the document.
I wish I could post an example image, but don't have 10 rep yet. Feel free to ask for a better description.
Can anyone shed some light on how to accomplish this?
I set the background colour of my webView to clearColor in my nib file and for me it works fine:
Let me know if it still doesn't work for you.

iOS Blur Background like iTunes Remote App

I'm new here so please bear with me.
Can you please help me make a transparent blured background like the one used in iTunes Remote iOS7 app in the store? Also, how is the text masked?
Screenshot here:
(source: rackcdn.com)
I found the "UIImage+ImageEffect" class made by Apple, in a WWDC example Apple posted here: https://developer.apple.com/downloads/index.action?name=WWDC%202013#.
Using this class, is's really simple to blur an image with this code: [image applyLightEffect]
where image as an instance of UIImage.
Here are the steps i took to make the text look like it's "cut" from the background view. Use this layering order:
Blurred Image
View with lower opacity (ex 80%) filled with a color. I used a white background color.
2.1. Set a label as a child of this view and set the tint color to Black.
Add any other content you want on top.
And voila! It magically works!
Use UIToolBar of UIKit framework which automatically comes with blur and transparent effect on background view (live).
Reason - Since UIToolBar inherits UIView so fundamentally there is no issue in using it in place of UIView.

Create UIView with custom shape

So I was wondering if there's a way to make a UIView with a custom shape.
I'm trying to make a piano keyboard so when the user touches the view a delegate method responds by playing a noise. The picture is a .png with the picture of the key and a transparent background.
Thanks in advance.
You can't make a UIView in the shape of, say, a triangle, but what you can do is make the view transparent, then add your non-transparent content to it.
For example, to make a view with a background of a png (with, I assume, partially transparent areas) you could make a transparent UIView and then add an image view to it. better yet, just use a UIImageView in the place.

Resources