2016-08-02 5 views

답변

1

첫째, 수입 MediaPlayer : 앱을 사용하는 동안 볼륨을 음소거하려면

import MediaPlayer 

는 그리고, applicationDidFinishLaunchingWithOptions에, AppDelegate로 이동하여 다음 코드를 입력 :

(MPVolumeView().subviews.filter{NSStringFromClass($0.classForCoder) == 
"MPVolumeSlider"}.first as? UISlider)?.setValue(0, animated: false) 

//# MARK: 0 represents the lowest volume and 1 the highest volume from "setValue(0, animated: false)" 
+1

에서 : 스위프트 : 프로그래밍 방식으로 아이폰 볼륨을 설정하는 방법] (http://stackoverflow.com/questions/36322856/swift-how-to-set-the-iphone-volume-programmatically) –