问题
I need to implement outer glow effect on UILabel (or CATextLayer) as above. I know to create glow effect on text, I need shadow with offset (0,0). I've touched down to the quartz2D level, following is the code I'm using:
_backgroundDownLabel.layer.shadowColor = self.glowColor.CGColor; // red
_backgroundDownLabel.layer.shadowOffset = CGSizeMake(0, 0);
_backgroundDownLabel.layer.shadowOpacity = 1;
_backgroundDownLabel.layer.shadowRadius = self.glowAmount; // tried 1-10
_backgroundDownLabel.layer.masksToBounds = NO;
Problem: when I use RGB(1,0,0) color as the shadow color to create a red glow, the outcome is too subtle, meaning the red glow is not strong enough. On the other hand, client designer sent me a PSD file, in which the glow color is bright and strong. I guess it's not a simple glow but some Photoshop filter, maybe outer glow or some combination.
So, is there a way by code that I can do something similar?
回答1:
I'm not sure exactly what you are asking, but I think this will be of help: IPhone Text Glow Effect
Also, if you want to create a red glow like the .psd above, why not just convert it to .png and use it in your app?
EDIT:
I just found a solution to your problem from Brad Larson's Advanced iPhone Development Courses on iTunes U. You will have to download the course notes over at Brad Larson's profile (You have to have Voodoo Pad to open them) and go into the Quartz 2D Drawing notes under "schedule." Then you'll have to download the sample code called "QuartzExample".
Hope this helps you out if you haven't found a solution already.
回答2:
If you really want a full control, then you have to draw... Something like:
for (int i = 0; i < SOME_NUMBER; i++)
{
CGContextSetShadowWithColor(UIGraphicsGetCurrentContext(),
CGSizeZero,
i * SOME_FACTOR,
[UIColor redColor].CGColor);
[text drawAtPoint...
}
And then experiment with SOME_NUMBER
and SOME_FACTOR
.
来源:https://stackoverflow.com/questions/8052987/how-to-create-a-strong-red-glow-effect-on-uilabel