我正在研究利用此GitHub应用程序代码TextGlowDemo
中的代码的项目。该应用程序基本上使用QuartzCore框架通过重写drawTextInRect并添加CGContextSetShadow
和CGContextSetShadowWithColor
以使阴影看起来像发光的文本来为uilabel添加阴影。该程序在ios 6中完美工作,但在ios7中,发光神秘地消失。我没有得到任何有关已废弃方法的警告,所以我不知道发生了什么,有什么想法?我不明白为什么TextGlowDemo不再在ios7中运行
整个项目可以在这里找到: https://github.com/andrewgleave/TextGlowDemo
这里是绘制辉光
- (void)drawTextInRect:(CGRect)rect
{
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSaveGState(context);
CGContextSetShadow(context, self.glowOffset, self.glowAmount);
CGContextSetShadowWithColor(context, self.glowOffset, self.glowAmount, glowColorRef);
[super drawTextInRect:rect];
CGContextRestoreGState(context);
}