---
title: "setShadow(offset:blur:)"
framework: coregraphics
role: symbol
role_heading: Instance Method
path: "coregraphics/cgcontext/setshadow(offset:blur:)"
---

# setShadow(offset:blur:)

Enables shadowing in a graphics context.

## Declaration

```swift
func setShadow(offset: CGSize, blur: CGFloat)
```

## Parameters

- `offset`: Specifies a translation of the context’s coordinate system, to establish an offset for the shadow ({0,0} specifies a light source immediately above the screen).
- `blur`: A non-negative number specifying the amount of blur.

## Discussion

Discussion Shadow parameters are part of the graphics state in a context. After shadowing is set, all objects drawn are shadowed using a black color with 1/3 alpha (in effect, RGBA = {0, 0, 0, 1.0/3.0}) in the DeviceRGB color space. To turn off shadowing: Use the standard save/restore mechanism for the graphics state. Use setShadow(offset:blur:color:) to set the shadow color to a fully transparent color (or pass NULL as the color).

## See Also

### Setting Fill, Stroke, and Shadow Colors

- [setFillColor(_:)](coregraphics/cgcontext/setfillcolor(_:)-8lhn8.md)
- [setFillColor(_:)](coregraphics/cgcontext/setfillcolor(_:)-756dy.md)
- [setFillColor(cyan:magenta:yellow:black:alpha:)](coregraphics/cgcontext/setfillcolor(cyan:magenta:yellow:black:alpha:).md)
- [setFillColor(gray:alpha:)](coregraphics/cgcontext/setfillcolor(gray:alpha:).md)
- [setFillColor(red:green:blue:alpha:)](coregraphics/cgcontext/setfillcolor(red:green:blue:alpha:).md)
- [setFillColorSpace(_:)](coregraphics/cgcontext/setfillcolorspace(_:).md)
- [setShadow(offset:blur:color:)](coregraphics/cgcontext/setshadow(offset:blur:color:).md)
- [setStrokeColor(_:)](coregraphics/cgcontext/setstrokecolor(_:)-1sskg.md)
- [setStrokeColor(_:)](coregraphics/cgcontext/setstrokecolor(_:)-4pd8p.md)
- [setStrokeColor(cyan:magenta:yellow:black:alpha:)](coregraphics/cgcontext/setstrokecolor(cyan:magenta:yellow:black:alpha:).md)
- [setStrokeColor(gray:alpha:)](coregraphics/cgcontext/setstrokecolor(gray:alpha:).md)
- [setStrokeColor(red:green:blue:alpha:)](coregraphics/cgcontext/setstrokecolor(red:green:blue:alpha:).md)
- [setStrokeColorSpace(_:)](coregraphics/cgcontext/setstrokecolorspace(_:).md)
- [setStrokePattern(_:colorComponents:)](coregraphics/cgcontext/setstrokepattern(_:colorcomponents:).md)
- [setAlpha(_:)](coregraphics/cgcontext/setalpha(_:).md)
