我正在开发一个利用此GitHub应用程序TextGlowDemo
中的代码的项目。该应用程序基本上使用QuartzCore Framework通过覆盖drawTextInRect并添加CGContextSetShadow
和CGContextSetShadowWithColor
来向uilabel添加阴影,以使投影看起来像发光文本。该程序在ios 6中完美运行,但在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);
}
答案 0 :(得分:1)
看起来最新的IOS升级解决了这个问题。在我有机会尝试Brett的解决方案之前,它就开始工作了。
答案 1 :(得分:0)
我相信你的self.glowOffset可能是CGSizeZero。我不知道为什么,但在iOS7中你没有看到带有CGMakeSize(0.0f,0.0f)偏移的阴影。