<!--
{
  "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 -"
  ],
  "documentType" : "symbol",
  "framework" : "MapKit",
  "identifier" : "/documentation/MapKit/MKGradientPolylineRenderer",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "MapKit"
    ],
    "preciseIdentifier" : "c:objc(cs)MKGradientPolylineRenderer"
  },
  "title" : "MKGradientPolylineRenderer"
}
-->

# MKGradientPolylineRenderer

A visual representation of any polyline overlay object with a gradient.

```
class MKGradientPolylineRenderer
```

## Overview

This renderer only applies a stroke to the line; it doesn’t fill it. Set the gradients with [`setColors:atLocations:`](/documentation/MapKit/MKGradientPolylineRenderer/setColors:atLocations:) and pair colors to locations that MapKit represents as unit distance values along the distance of the polyline. Don’t subclass `MKGradientPolylineRenderer`. Use the class as-is.

The gradient displays itself along the direction of the line.

## Topics

### Accessing the gradient colors

[`setColors(_:locations:)`](/documentation/MapKit/MKGradientPolylineRenderer/setColors(_:locations:)-3xrou)

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

[`setColors(_:locations:)`](/documentation/MapKit/MKGradientPolylineRenderer/setColors(_:locations:)-1tuft)

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

[`setColors:atLocations:`](/documentation/MapKit/MKGradientPolylineRenderer/setColors:atLocations:)

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

[`colors`](/documentation/MapKit/MKGradientPolylineRenderer/colors)

An array that represents the gradient’s color transition points.

[`locations`](/documentation/MapKit/MKGradientPolylineRenderer/locations-7k6qz)

An array of location indexes that correspond to their respective colors.

[`locations`](/documentation/MapKit/MKGradientPolylineRenderer/locations-50knt)

An array of location indices corresponding to their respective colors.



---

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)