Using existing system sounds in iOS App [swift|

后端 未结 3 715
北荒
北荒 2020-12-04 15:51

Is it possible to use the existing Apple system sounds in my own app? I would like to write a sample app in Swift that does the following steps:

  1. Read/Get a lis
3条回答
  •  天涯浪人
    2020-12-04 16:06

    You can use this Swift 5 code to play system sounds:

    // import this
    import AVFoundation
    
    // create a sound ID, in this case its the tweet sound.
    let systemSoundID: SystemSoundID = 1016
    
    // to play sound
    AudioServicesPlaySystemSound (systemSoundID)
    

    The most up to date list of sounds I could find are here.

    Documentation Reference

提交回复
热议问题