How to solve preview bug in SwiftUI? [XCode 13]

249 Views Asked by At

I am using a mapkit element and want to see the preview. But, the preview option provided by Xcode is showing wrong color for map annotations.

For example, If I set annotation color as yellow, In preview I'm getting blue color.

Sample code:

Map(coordinateRegion: $region, annotationItems: locations, annotationContent: { item in
            // a. Old style, always static
            MapPin(coordinate: item.location, tint: .accentColor)
        })

Note my accent color is: yellow.

Is there any solution to solve this preview bug?

1

There are 1 best solutions below

0
On

Well. I have found that there is no problem in the code.

It can be a bug of XCode 13.2.1's preview system. Because I have got the correct output using simulator without changing anything in the code. So, nothing to worry at all if you face this kind of issue sometimes.

Still, if anyone have anything to share on top my answer, you are welcome.