我想在Core Graphics中做类似于Photoshops内部阴影效果的操作.如果我使用此效果绘制/填充路径,我想获得类似于以下内容的内容:alt text http://i45.tinypic.com/357kile.png
我试图为UILabel实现这种发光效果,如下所示:

我有子类UILabel,并创建了一个自定义标签类,添加了外部阴影.
编辑:这是我在自定义Label类中用于外部阴影/发光的代码:
- (void)drawTextInRect:(CGRect)rect {
UIColor *insideColor;
UIColor *blurColor;
CGContextRef ctx = UIGraphicsGetCurrentContext();
insideColor =[UIColor colorWithRed:255/255.0 green:255/255.0 blue:191/255.0 alpha:1];
blurColor =[UIColor orangeColor];
CGContextSetFillColorWithColor(ctx, insideColor.CGColor);
CGContextSetShadowWithColor(ctx, CGSizeMake(0, 0), self.glowAmount, blurColor.CGColor);
CGContextSetTextDrawingMode(ctx, kCGTextFillStroke);
[self.text drawInRect:self.bounds withFont:self.font lineBreakMode:self.lineBreakMode alignment:self.textAlignment];
}
Run Code Online (Sandbox Code Playgroud)
但这给了我以下结果

正如你所看到的,由于缺少内阴影,这缺乏预期的效果.谁能建议如何实现这一目标?
谢谢!
我想将内阴影应用于UILabel.我有一个解决方案,但它还不够好.谁有更好的解决方案?
// UILabel subclass
- (void) drawTextInRect:(CGRect)rect {
CGSize myShadowOffset = CGSizeMake(0, 2);
float myColorValues[] = {255, 0, 0, 1};
CGContextRef myContext = UIGraphicsGetCurrentContext();
CGContextSaveGState(myContext);
CGColorSpaceRef myColorSpace = CGColorSpaceCreateDeviceRGB();
CGColorRef myColor = CGColorCreate(myColorSpace, myColorValues);
CGContextSetShadowWithColor (myContext, myShadowOffset, 5, myColor);
CGContextSetBlendMode(myContext, kCGBlendModeLighten);
[super drawTextInRect:rect];
CGColorRelease(myColor);
CGColorSpaceRelease(myColorSpace);
CGContextRestoreGState(myContext);
}
Run Code Online (Sandbox Code Playgroud)
我熟悉UILabel的图层属性,但shadow offset给我们一个外阴影,而不是内阴影(除非我遗漏了什么).