Posted at

Swiftで困っときに見るもの(音の取得と、アニメーションの設定)

More than 1 year has passed since last update.


音データを取得して表示させる

if SoundPlayServive.shared.isPlaying {

let plyersSelect: [Sound] = SoundPlayServive.shared.playingSounds
plyersSelect.forEach { selectPlyer in
print("\(selectPlyer.title)-\(selectPlyer.id): \(SoundPlayServive.shared.getVolume(with: selectPlyer.id))")
}
}


アニメーションの設定

//ボタンを揺らすアニメーション

UIView.animate(withDuration: 0.2, animations: {
self?.bookStatusButton.transform = CGAffineTransform(scaleX: 1.2, y: 1.2)
}, completion: { _ in
UIView.animate(withDuration: 0.2) {
self?.bookStatusButton.transform = CGAffineTransform.identity
}
})

参考:https://slack-redir.net/link?url=https%3A%2F%2Fqiita.com%2Fhayashi311%2Fitems%2F953d3282c6ffebf308df

                   UIView.animate(withDuration: 1.0, delay: 0.0, options: .curveEaseOut, animations: {

self.soundControlViews.frame = CGRect(x: soudViewsFrame.origin.x, y: soudViewsFrame.origin.y, width: soudViewsBounds.width, height : soudViewsBounds.height + addHights)
}, completion: nil)