我有一个带有animateWithDuration和setAnimationRepeatCount()
动画的脉冲矩形。animateWithDuration播放声音不重复
我试图在动画块中添加声音效果的女巫是同步“点击”。但音效只播放一次。我无法在任何地方找到任何提示。
UIView.animateWithDuration(0.5,
delay: 0,
options: UIViewAnimationOptions.AllowUserInteraction | UIViewAnimationOptions.CurveEaseOut | UIViewAnimationOptions.Repeat,
animations: {
UIView.setAnimationRepeatCount(4)
self.audioPlayer.play()
self.img_MotronomLight.alpha = 0.1
}, completion: nil)
声音效果应播放四次,但不播放。
音频执行:
//global:
var metronomClickSample = NSURL(fileURLWithPath: NSBundle.mainBundle().pathForResource("metronomeClick", ofType: "mp3")!)
var audioPlayer = AVAudioPlayer()
override func viewDidLoad() {
super.viewDidLoad()
audioPlayer = AVAudioPlayer(contentsOfURL: metronomClickSample, error: nil)
audioPlayer.prepareToPlay()
....
}
@IBAction func act_toggleStartTapped(sender: AnyObject) {
....
UIView.animateWithDuration(....
animations: {
UIView.setAnimationRepeatCount(4)
self.audioPlayer.play()
self.img_MotronomLight.alpha = 0.1
}, completion: nil)
}
动画重复吗? – ricky3350
声音是否播放?音频片段有多长? – dudeman
动画重复。声音只播放一次。音频剪辑只是一个短的点击:长度0.36秒,格式MP3 –