---
title: "setColors(_:locations:)"
framework: mapkit
role: symbol
role_heading: Instance Method
path: "mapkit/mkgradientpolylinerenderer/setcolors(_:locations:)-3xrou"
---

# setColors(_:locations:)

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

## Declaration

```swift
func setColors(_ colors: [UIColor], locations: [CGFloat])
```

## 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 locations.

## See Also

### Accessing the gradient colors

- [setColors(_:locations:)](mapkit/mkgradientpolylinerenderer/setcolors(_:locations:)-1tuft.md)
- [colors](mapkit/mkgradientpolylinerenderer/colors.md)
- [locations](mapkit/mkgradientpolylinerenderer/locations-7k6qz.md)
