MAC 触控板震动反馈

let performer = NSHapticFeedbackManager.defaultPerformer

performer.perform(.generic, performanceTime: .now)

NSHapticFeedbackPatterns

NSHapticFeedbackPatternsIs used to specify the type of tactile feedback, it takes one of the following values.

.LevelChange

.Alignment

.Generic

.LevelChangeIt is, if the user has changed the strength to press the track pad, used to feedback it. For example, if there is a button to accept the strength of the two-step, you will need to feed it back to the user when the user switches to the second stage from the first stage, but you specify this in such instances.

.AlignmentIt is used to perform the guide when the user or to resize or move the object. For example, you can get a tactile feedback, such as stick to grid when performing an operation of the control when the xib editor Xcode operating in Force Touch trackpad, similar to that of the implementation in the application as If you are to specify this.

.GenericIt is specified in case that does not apply to the above example.

NSHapticFeedbackPerformanceTime

NSHapticFeedbackPerformanceTimeSpecifies the timing at which the tactile feedback. .NowMake the feedback at the same time as the specified call and the but, .DrawCompletedfor leaving be delayed if you specify so far drawing complete, you can use both depending on the characteristics of the view.

Example

import Cocoa

let performer = NSHapticFeedbackManager.defaultPerformer()

for _ in 0..<10 {

performer.performFeedbackPattern(.Alignment, performanceTime: .Now)

sleep(1)

performer.performFeedbackPattern(.LevelChange, performanceTime: .Now)

sleep(1)

performer.performFeedbackPattern(.Generic, performanceTime: .Now)

sleep(1)

}

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容