我正在研究利用此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);
}