How do I blur whatever is behind a translucent UIImageView? - iphone

I have a translucent png image (made by turning down the opacity in Photoshop), and there's a UIImageView behind that translucent image. Is there any way to blur the parts of the UIImageView on the bottom that intersect with the UIImageView on top? Thanks!

Not aware of any code that will do that on its own, but you could 'fake it' by rendering the intersection of the views in a graphics context, then apply a blur effect to it. Then you could take the graphics context and insert a UIImageView with the resulting image in between the two views to simulate the effect. This method would not work very well if you have any sort of animation or otherwise changing the state of the images.

You may try setting alpha of the image to less than 1.

Related

Creating translucent UIView with gaussian blur

I am in the process of creating an app where I have a background image (a UIImageView with the frame set to the UIView's bounds and added as a subview).
I would like to now add a UIView that will be over the background image but will apply gaussian blur to the image behind, only over the area where the UIView is.
I have just tried to use GPUImage to create a blur, which looks good but it uses 2 UIImageViews (one large background and one behind the UIView, which is blurred). Unfortunately the image no longer matches up with the background.
Is there any way to get the UIView to blur only the area behind it? A bit like the UIView is frosting the image behind.
Thanks!
Try FXBlurView from here - https://github.com/nicklockwood/FXBlurView
It should work.

Feathering NSView Opacity

I wish to have an NSView with one side of it fading out to an alpha of 0.0f. What is the best practice for doing this? This effect is similar to that of feathering a selection in Photoshop or Pixelmator.
Give your view a backing store layer (check out the NSView wantsLayer and layer properties). Make a CAGradientLayer and set its your backing store layer's mask.
The most basic way to do this is to draw a gradient and, in your view's drawRect:, call CGContextClipToMask() to use the gradient image as a mask.
Make a .png image that starts from transparent and fades out to the color that you want to your NSView to fade out to.
Then add an image element that covers all the NSView and display the .png image that you made before.
That should do it.

CGContext transparency problem

I have an UIView which has white background color set.
I have set the blending mode of the CGContext of the UIView as 'kCGBlendModeCopy'.
Then,
1. Draw an UIImage in that CGContext
2. Draw a path with alpha as 0 in that context.
The transparent area covered by the path appears in black whereas my expected output was that it should be UIView's background color (i.e. white).
Does anyone knows what is the problem here?
Thanks in advance,
Regards,
Deepa
There is no problem here and hence no solution. Since we are drawing on the UIView's context with transparency, we can see the screen that is in black color. The drawing hierarchy is like this:
1. Black screen
2. On this transparent window is kept. Through this window we can see the screen
3. A view that is partially transparent is kept on this window. Through this view we can see window(Window is transparent and hence we can see screen)
(View is partially transparent because I am drawing part of the View with transparent path)
Hope this helps you Naren
Maybe this article can help you..
http://losingfight.com/blog/2007/08/18/how-to-implement-a-basic-bitmap-brush/
I understood the problem after putting some more effort:
CGContext is not a separate drawing layer of UIView. UIView is a cocoa wrapper for CGContext drawing. Since I am drawing the path with transparency, the screen behind the UIView is visible.

iPhone animation with stretchable image

I got a UIView subclass that draws a UIImage as its background. The image is created using the stretchableImageWithLeftCapWidth:topCapHeight: method, it has round edges.
I also use an animation block inside of which I resize my view. I had hoped that during animation, the drawRect:method would get called sometimes, which would result in the background image getting drawn correctly.
Unfortunately, the animation seems to render the image and then just rescale it during the animation, which obviously makes the formerly round edges getting nastily stretched.
The only workaround I can imagine is put three separate UIImageViews (top cap, middle fill, bottom cap) above my original background image and then reposition the caps images and scaling the fill image. However, this seems quite complicated...
Is there any better way I can prevent this from happening?
EDIT: Found this. Sounds bad...
While digging through some Apple docs, I coincidentally found the solution to my problem. All you have to do is play with UIView's contentStretch parameter. It allows you to manually specify the area of your view that gets stretched during animation.

Why does UIImageView appear to be partially transparent

I have a simple app that just displays a UIImageView. For some reason the image appears that it is partially transparent as it is much lighter than if I view the same image in photoshop. Any suggestions...I though by default a UIView is opaque.
You have probably changed the alpha of your imageView or the view itself. check for the the transparency of your imageview also. Because the default alpha of the imageview is 1 and opacity is also set to 100%. You might have chane one of these otherwise this is the problem of your image only
I don't believe that UIImageView is by default partially transparent? Try changing the background colour of the application and see if that affects the outcome of your image, if it is transparent it should be darker with a black background rather than white.