'Sound overlaps with voiceover and AVFoundation player

In my iOS app, I have a button which can play sound after clicking on it, however this button has a voiceover function at the same time. When I click on the button, both of the two sounds overlap.



Solution 1:[1]

Swift 5

button.accessibilityTraits = .playsSound

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Mykyta Khlamov