Function

CGContextSetShadow

Enables shadowing in a graphics context.

Declaration

void CGContextSetShadow(CGContextRef c, CGSize offset, CGFloat blur);

Parameters

context

A graphics context.

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

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 CGContextSetShadowWithColor to set the shadow color to a fully transparent color (or pass NULL as the color).

See Also

Setting Color, Color Space, and Shadow Values

CGContextSetAlpha

Sets the opacity level for objects drawn in a graphics context.

CGContextSetCMYKFillColor

Sets the current fill color to a value in the DeviceCMYK color space.

CGContextSetFillColor

Sets the current fill color.

CGContextSetCMYKStrokeColor

Sets the current stroke color to a value in the DeviceCMYK color space.

CGContextSetFillColorSpace

Sets the fill color space in a graphics context.

CGContextSetFillColorWithColor

Sets the current fill color in a graphics context, using a CGColor.

CGContextSetGrayFillColor

Sets the current fill color to a value in the DeviceGray color space.

CGContextSetGrayStrokeColor

Sets the current stroke color to a value in the DeviceGray color space.

CGContextSetRGBFillColor

Sets the current fill color to a value in the DeviceRGB color space.

CGContextSetRGBStrokeColor

Sets the current stroke color to a value in the DeviceRGB color space.

CGContextSetShadowWithColor

Enables shadowing with color a graphics context.

CGContextSetStrokeColor

Sets the current stroke color.

CGContextSetStrokeColorSpace

Sets the stroke color space in a graphics context.

CGContextSetStrokeColorWithColor

Sets the current stroke color in a context, using a CGColor.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software