<!--
{
  "availability" : [
    "iOS: 14.0.0 -",
    "iPadOS: 14.0.0 -",
    "macCatalyst: 14.0.0 -",
    "macOS: 11.0.0 -",
    "tvOS: 14.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "MapKit",
  "identifier" : "/documentation/MapKit/MKGradientPolylineRenderer/setColors:atLocations:",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "MapKit"
    ],
    "preciseIdentifier" : "c:objc(cs)MKGradientPolylineRenderer(im)setColors:atLocations:"
  },
  "title" : "setColors:atLocations:"
}
-->

# setColors:atLocations:

Sets the colors and corresponding unit distance values to create gradients.

iOS, iPadOS, Mac Catalyst, tvOS, visionOS, watchOS:

```
- (void) setColors:(NSArray<UIColor *> *) colors atLocations:(NSArray<NSNumber *> *) locations;
```

macOS:

```
- (void) setColors:(NSArray<NSColor *> *) colors atLocations:(NSArray<NSNumber *> *) locations;
```

## Parameters

`colors`

An array of colors making up the transition points of the gradient.

`locations`

An array of unit distance values that correspond to the provided colors.

## Discussion

The unit distance value of `0` represents the start of the polyline, and `1` represents the end of the polyline. A gradient may have any number of steps along the length of the polyline.

To determine a location along the polyline, use [`location(atPointIndex:)`](/documentation/MapKit/MKMultiPoint/location(atPointIndex:)), or retrieve a set of locations using [`locationsAtPointIndexes:`](/documentation/MapKit/MKMultiPoint/locationsAtPointIndexes:).

---

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)