我们可以让iPhone像Datepicker卷轴一样振动吗?

问题描述 投票:1回答:2

当您使用Datepicker时,无论何时滚动日期,iPhone都会轻微振动。我知道我们可以使用AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);来进行正常的振动。但是我们可以像Datepicker一样制造振动吗?

ios cocoa-touch
2个回答
2
投票

我相信你正在寻找UIFeedbackGenerator API。 https://developer.apple.com/documentation/uikit/uifeedbackgenerator


0
投票

迅速:

if #available(iOS 10.0, *) {
    let generator = UISelectionFeedbackGenerator()
    generator.selectionChanged()
}
© www.soinside.com 2019 - 2024. All rights reserved.