On the new iOS 10 release, I noticed that my custom GMSMarker
views were rendering differently then they used to. I am currently on Google Maps 2.10 which is the latest.
My Setup
First, I create a GMSMarker
in a very basic way just for this example.
GMSMarker *marker = [GMSMarker markerWithPosition:initialPosition];
marker.appearAnimation = kGMSMarkerAnimationNone;
marker.tracksViewChanges = NO;
marker.iconView = markerView;
marker.groundAnchor = CGPointMake(0.5, 0.5);
marker.map = self.mapView;
In the above code I am creating the GMSMarker
and assigning it a markerView
which is a custom UIView
subclass that I have written. That implementation is below and is called GLMarkerView
. Switching languages and it will be in Swift 3.0.
@objc class GLMarkerView: UIView {
init(store: GLStore?) {
let circleFrame = CGRect(x: 0, y: 0, width: 40.0, height: 40.0)
super.init(frame: circleFrame)
backgroundColor = UIColor.red.withAlphaComponent(0.4)
layer.cornerRadius = 20.0
isOpaque = false
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}
The Results
So everything above is a very simple layout to make sure that I was not doing anything specific that was causing this problem. Based on the code above, I should see the markers on the GMSMapView
and they should be translucent red circles. On iOS 9 and below this works perfectly. And I get the following result:
What the Map looks like on iOS 9
However when I run the exact same code on iOS 10, I get the following view:
What the Map looks like on iOS 10
The Problem
For some reason there is this darker background added to the rendering that I have no idea where it is coming from. Ran view debugging, changed the UIView
to set isOpaque = false
. Tried a wide array of things to get this to render correctly.
One thing I noticed is that it is not just transparency that this effects. If I run the same code with a white background, the circles have strange anti-aliasing problems with their borders.
If anyone has seen this issue and knows of a way to fix it, any help would be more than appreciated. If you need any more information on this problem or have any questions about the implementation, please feel free to ask and I will respond as quickly as I can. Thanks in advance!