To create a box that plays a sound upon tap and shows a volume slider upon long press, follow these steps:
AVFoundation framework:main.swift35 chars3 lines
main.swift44 chars2 linesAVAudioPlayer object and load the sound file into it:main.swift325 chars12 linesGesture modifier to handle tap and long press gestures:main.swift770 chars31 linesmain.swift44 chars2 linesZStack to display the volume slider only when isChangingVolume is true:main.swift516 chars20 linesThe final SoundBox struct should look something like this:
main.swift1599 chars56 linesgistlibby LogSnag