使用iOS App中的现有系统声音[swift | [英] Using existing system sounds in iOS App [swift|

查看:297
本文介绍了使用iOS App中的现有系统声音[swift |的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在我自己的应用中使用现有的Apple系统声音?我想在Swift中编写一个示例应用程序,它执行以下步骤:

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. 读取/获取设备上所有可用systemSounds的列表(我认为它们位于 / System / Library / Audio / UISounds /

  2. 在屏幕上显示列表

  3. 如果我触摸一个列表项,播放这些声音

所以它基本相同,就像当你在你的iPhone上选择一个新的铃声。

So its basically the same, like when you choose a new ringtone on your iPhone.

我认为有些应用正在使用这种声音,还是他们复制/购买了它?

I think some apps are using this sounds, or have they copied/bought it?

感谢和问候
Jens

Thanks and regards Jens

推荐答案

您可以使用此Swift 4代码播放系统声音:

You can use this Swift 4 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.

文档参考

这篇关于使用iOS App中的现有系统声音[swift |的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆