It appears that setting the text of a label can have the side effect of increasing the opacity of a MKCircle that has been added to an MKMapView.
Here is what's going on:
First I have this delegate function to handle rendering my overylay
func mapView(_ mapView: MKMapView, rendererFor overlay: MKOverlay) -> MKOverlayRenderer {
let diskRenderer: MKCircleRenderer = MKCircleRenderer.init(overlay: overlay)
diskRenderer.fillColor = UIColor.init(red: 0, green: 255, blue: 255, alpha: 0.10)
diskRenderer.strokeColor = UIColor.init(red:0, green: 0, blue: 0, alpha: 0.25)
return diskRenderer
}
Then I add it to the MKMapView
map.delegate = self
let diskOverlay: MKCircle = MKCircle.init(center: location, radius: diskRadius)
map.add(diskOverlay)
All seems good. Now at the same time, I have a custom UIControl called YSRangeSlider that I got from cocoapods. When the user moves the thumbs on this slider, a function gets called that updates the text of some labels according to whatever the current values are on the slider. Here is that function.
func setPlayerLabels() {
let lowerValue = Int(playersSlider.minimumSelectedValue)
let upperValue = Int(playersSlider.maximumSelectedValue)
minPlayersLabel.text = "\(lowerValue)"
maxPlayersLabel.text = "\(upperValue)"
}
Now here is the really really weird thing. When I launch the app and segue to this ViewController and then start sliding a thumb on the slider, the MKCircle - that is the faint disk being shown on the map, becomes more and more opaque until it is solid filled. But if I comment out the two label.text = "---" going on in the function above, this strange behavior no longer occurs.
Below you can see the overlay as it looks initially (low opacity) and then after getting messed up (opaque). I don't know the deeper reason of why this is happening nor how to fix it. This is XCode 8 with Swift 3.
- To make things even worse, I should mention that sometimes the map renders the disk overlay as if it was on a large square tile casting a shadow beneath it, a shadow who's opacity goes towards opaque just like the overlay itself. Also if I zoom out some before touching the slider, it so happens that sliding a thumb on the slider then causes the map to zoom back in on top of the already mentioned opacity changes.