<!--
{
  "availability" : [
    "macOS: 10.5.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSGradient/init(starting:ending:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSGradient(im)initWithStartingColor:endingColor:"
  },
  "title" : "init(starting:ending:)"
}
-->

# init(starting:ending:)

Initializes a newly allocated gradient object with two colors.

```
convenience init?(starting startingColor: NSColor, ending endingColor: NSColor)
```

## Parameters

`startingColor`

The starting color of the gradient. The location of this color is fixed at 0.0.

`endingColor`

The ending color of the gradient. The location of this color is fixed at 1.0.

## Return Value

The initialized `NSGradient` object.

## Discussion

---

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)