CGContextRef currentContext = UIGraphicsGetCurrentContext();//获取图形上下文状态 CGContextSaveGState(currentContext);// 将当前图形上下文状态保存至堆栈 CGContextSetShadow(currentContext, CGSizeMake(4,50), 10);// 设置阴影 UIImage *logoImage = [UIImage imageNamed:@"icon-10_blue.png"]; [logoImage drawInRect:rect]; CGContextRestoreGState(currentContext);// 把堆栈顶部项弹出,返回至以前的图形状态