GradientPathRenderer Save

Renders MKPolyline with a fancy multicoloured gradient fill

Project README


Renders MKPolyline with a fancy multicoloured gradient fill similar to the Nike + Running App. A drop in replacement for MKPolylineRenderer, supports multiple colour stops and an optional border.


  1. Add GradientPathRenderer.swift to your project
  2. Inside rendererForOverlay delegate method, use GradientPathRenderer as you would an MKPolyLineRenderer
func mapView(mapView: MKMapView, rendererForOverlay overlay: MKOverlay) -> MKOverlayRenderer {
    if let overlay = overlay as? MKPolyline {
            /// define a list of colors you want in your gradient
            let gradientColors = [,, UIColor.yellow,]

            /// Initialise a GradientPathRenderer with the colors
            let polylineRenderer = GradientPathRenderer(polyline: overlay, colors: gradientColors)

            /// set a linewidth
            polylineRenderer.lineWidth = 7
            return polylineRenderer
  1. Optionally include border and borderColor variables to render a border on the polyline
polylineRenderer.border = true
polylineRenderer.borderColor = /* defaults to white if not specified*/
Open Source Agenda is not affiliated with "GradientPathRenderer" Project. README Source: joeltrew/GradientPathRenderer
Open Issues
Last Commit
6 months ago

Open Source Agenda Badge

Open Source Agenda Rating