Easy way to blur label - iphone

Need to create blurred shadow under UILabel. Same text but with blur and offset. Since NSShadow not supported in the iPhone SDK only way I see is Quartz render. Is there simpliest solution ?
Thanks

I provide code to draw a shadow around a UILabel in my answer to this question. For an example of this in action, see the sample project I've created. A shadow of the same color as the text provides a nice blurring effect to the text in a label.

For 3.1 and below, no. You must use CoreGraphics.
For 3.2 and above, you can get the layer, and set the shadowRadius property.

Related

CALayer BlendMode

I am creating a simple iOS application in which I have two CALayers, I want to add the blend effect on the upper CALayer to display the content on the second layer. I dont want to do it alpha. Is there any way to do this without changing the alpha?
iOS (as of 5.1) does not currently support any blend effects on CALayer. In my testing, the compositingFilter property is ignored.
There's a tricky way to achieve this.
compositingFilter works but filter names should be like subtractBlendMode (lower camel case), not CISubtractBlendMode.
Here is a demo:
https://github.com/arthurschiller/CompositingFilters
Use property
opacity
of CALayer as there is nothing such as alpha. Its opacity instead of alpha
so try setting opacity of the layers.

thick shadow with no blur on UILabel

I am trying to add a thick shadow to a UILabel, without any blur. In photoshop I would use the "Spread" option to make the shadow look like this. It's for a comic book themed UI in an app I am developing. I cannot use images as the text is dynamic and different for each user.
Here is what I am after (on the left) and here is as far as I have gotten so far with CGShadowWithColor (on the right):
Anyone know how I can achieve this result?
A quick hack to try would be to have several black UILabels below the white one, each offset slightly.

UIBarButtonItem clone

I have an UIButton subclass and I need its look
to be identical to an UIBarButtonItem when placed on the
classic blue tinted navigation bar.
The UIBarButtonItem has a border with a kind-of gradient,
being darker at the top and blue-ish at the bottom, which
I suspect it's done with some alpha trick. The bottom
looks recessed too.
There's also some overlay which makes the button a little bit darker
and even more when in the selected state.
Can anyone help?
The short answer is that you are going to have to spend some time learning how to draw gradients and shadows in Core Graphics.
The relevant documentation is called "Quartz 2D Programming Guide".
After you learn how to draw shadows and gradients, you are going to have to spend quite a bit of time zoomed in comparing what you are drawing vs what the button looks like.
You didn't ask, but this is what I would do:
Subclass UIBarButtonItem and add your custom functionality in there. Let UIBarButtonItem draw itself.
It might be easier for you just to use a photoshopped image. Use the image for your button. This way you don't have to worry about custom drawing code.
You can use Three20 library,
specially have a look at sample TTCatalog app.
Look at the source file "StyleTestController.m"
https://github.com/facebook/three20/blob/master/samples/TTCatalog/Classes/StyleTestController.m
I'm sure you'll find your answer here.
Cheers,

Can i specify a color to be transparent

I have a UIImage, the background of it is white. I want the background of this UIImage to be transparent to its parent view. Is this possible?
One word answer- No. As robin said you have to use photo editing softwares to accomplish that. it cannot be done iphone(easily)..
I am not going to suggest that it is easy, but you should take a look at CGImageCreateWithMaskingColors, which is described in the Quartz 2D Programming Guide: Bitmap Images and Image Masks
You can't specify the transparency of a color from an image, but you could make a PNG image which has a transparency in the places you want it to be transparent.

Replicating Mail Contact "Bubble" in iPhone SDK

When creating a new message using Mail on the iPhone, and after typing the contact, a blue "bubble" appears around the text. Is there some way I can replicate this behavior in my own application?
Thanks for any help!
The way I do this and probably the easiest way is with a custom UIView. You can draw inside a clipped rounded path with a blue gradient then draw the text on top of it.
You could also take a look at the Three20 project, which has a similar control. However, it's very complicated if you're just looking for that blue bubble.