animate MKPolygon alpha - complex polygon.

i am writing an app that user polygonal outlines of nature reserves from a third party web site. One, and only one, polygonal outline may be displayed at any time on a map but should fade out when the user interacts with the screen. This is done with:


func fadeAllPolygons(){

let overlays = algarveMap.overlays

for overlay in overlays

{

if overlay is MKPolygon

{

let t=algarveMap.renderer(for: overlay)

UIView.animate(withDuration: 1.5){

t?.alpha=0

}

}

}

}


Initially this worked well but as more polygons were added it was noted that some of them would not fade out correctly i.e. were not being animated. It appears that only "simple" polygons are animated, "complex" polygons do not get animated.


Example - examining t from above code:


Printing description of t.some:

(MKOverlayPathRenderer) baseMKOverlayPathRenderer@0 = {

baseMKOverlayRenderer@0 = {

baseNSObject@0 = {

isa = MKPolygonRenderer

}

_overlay = some {

some = 0x0000600003fa2bc0 {

baseMKMultiPoint@0 = {

baseMKShape@0 = {

baseNSObject@0 = {

isa = MKPolygon

}

_title = "Serra de Monchique"

_subtitle = nil

}

_pointCount = 10596

}

_interiorPolygons = nil

_isDefinitelyConvex = false

_simple = true


etc....


in this example the polygon would fade out correctly but when:


_simple = false


the polygon would not fade out!


It is possible to find all of the points that cause the polygon to become complex and fix them but it takes ages.


Does anyone know a workaround for this?