<!--
{
  "availability" : [
    "iOS: 6.0.0 -",
    "iPadOS: 6.0.0 -",
    "macCatalyst: 13.1.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "UIKit",
  "identifier" : "/documentation/UIKit/NSShadow",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSShadow"
  },
  "title" : "NSShadow"
}
-->

# NSShadow

An object you use to specify attributes to create and style a drop shadow during drawing operations.

```
class NSShadow
```

## Overview

When you create shadows, the system draws them in the default user coordinate space, where coordinates are independent from the pixel values of any particular device. Rotations, translations, and other transformations of the current transformation matrix (CTM) don’t affect the shadow or the apparent position of the shadow’s light source.

A shadow has two positional parameters: an x-offset and a y-offset. Express these values with a single size data type (<doc://com.apple.documentation/documentation/CoreFoundation/CGSize> in iOS, <doc://com.apple.documentation/documentation/Foundation/NSSize> in macOS), using the units of the default user coordinate space. Positive values for these offsets extend down and to the right from the user’s perspective.

In addition to its positional parameters, a shadow also contains a blur radius, which specifies how much the system blurs a drawn object’s image mask before compositing the image onto the destination. A value of `0` produces no blur. Larger values produce an increasingly large blurred shadow.

You can use an [`NSShadow`](/documentation/UIKit/NSShadow) object in one of two ways. First, you can set it, like a color or a font, where `NSShadow` attributes apply to everything you draw until you apply another shadow or restore a previous graphics state. Second, you can use an `NSShadow` instance as the value for the <doc://com.apple.documentation/documentation/Foundation/NSAttributedString/Key/shadow> text attribute in Swift or the [`NSShadowAttributeName`](/documentation/UIKit/NSShadowAttributeName) text attribute in Objective-C, so the system applies the shadow to the glyphs corresponding to the characters bearing this attribute.

## Topics

### Creating a shadow

[`-  init`](/documentation/UIKit/NSShadow/init())

Creates a shadow object with default values.

[`-  initWithCoder:`](/documentation/UIKit/NSShadow/init(coder:))

Creates a shadow object from data in an unarchiver.

### Managing a shadow

[`shadowOffset`](/documentation/UIKit/NSShadow/shadowOffset)

The shadow’s relative position, which you specify with horizontal and vertical offset values.

[`shadowBlurRadius`](/documentation/UIKit/NSShadow/shadowBlurRadius)

The blur radius of the shadow.

[`shadowColor`](/documentation/UIKit/NSShadow/shadowColor)

The color of the shadow.

### Setting a shadow

  <doc://com.apple.documentation/documentation/AppKit/NSShadow/set()>

## Relationships

### Conforms To

[`CustomDebugStringConvertible`](/documentation/Swift/CustomDebugStringConvertible)

[`NSSecureCoding`](/documentation/Foundation/NSSecureCoding)

[`CustomStringConvertible`](/documentation/Swift/CustomStringConvertible)

[`NSObjectProtocol`](/documentation/ObjectiveC/NSObjectProtocol)

[`CVarArg`](/documentation/Swift/CVarArg)

[`NSCoding`](/documentation/Foundation/NSCoding)

[`NSCopying`](/documentation/Foundation/NSCopying)

[`Hashable`](/documentation/Swift/Hashable)

[`Equatable`](/documentation/Swift/Equatable)

### Inherits From

[`NSObject-swift.class`](/documentation/ObjectiveC/NSObject-swift.class)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)