注释 onTapGesture 会激活声音。但是振动不起作用。如何同时实现声音和振动?
为什么会出现这个问题?
let feedback = UIImpactFeedbackGenerator(style: .soft)
func activeNum() {
playSound(sound: "casino-chips", type: "mp3")
}
var body: some View {
ZStack {
VStack(spacing: 0) {
LogoView()
Spacer()
Button(action: {
self.activeNum()
}) {
Image(systemName: "heart.fill")
.resizable()
.frame(width: 100, height: 100, alignment: .center)
.foregroundColor(.gray)
// .onTapGesture {
// feedback.impactOccurred()
// }
}
Spacer()
}
}
}