CGContextRef currentContext = UIGraphicsGetCurrentContext();
    CGContextSaveGState(currentContext);
    
    // 默认的灰色阴影
    CGContextSetShadow(currentContext, CGSizeMake(4, 7), 3);
    
    //自定义颜色的阴影
    // CGFloat components[4] = {1.0,0.0,0.0,1.0};
    // CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
    // CGColorRef color = (CGColorRef)CGColorCreate(colorSpace, components);
    // CGContextSetShadowWithColor(currentContext, CGSizeMake(4, 3), 1, color);
    // CGColorSpaceRelease(colorSpace);
    
    //在这里绘制的图形会产生阴影的效果
    
    UIImage *logoImage = [UIImage imageNamed:@"demo1.png"];
    [logoImage drawInRect:CGRectMake(center.x - 100, center.y - 100, 200, 200)];
    
    CGContextRestoreGState(currentContext);

    效果图如下