简体   繁体   中英

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

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM