---
title: "setColors:atLocations:"
framework: mapkit
role: symbol
role_heading: Instance Method
path: "mapkit/mkgradientpolylinerenderer/setcolors:atlocations:"
---

# setColors:atLocations:

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

## Declaration

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

```occ
- (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

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:), or retrieve a set of locations using locationsAtPointIndexes:.

## See Also

### Accessing the gradient colors

- [colors](mapkit/mkgradientpolylinerenderer/colors.md)
- [locations](mapkit/mkgradientpolylinerenderer/locations-50knt.md)
