uiimpactfeedbackgenerator类的有效值范围是什么?

发布于 2025-02-12 18:38:10 字数 1186 浏览 0 评论 0原文

ios Uikit类 uiimpactfeedbackgenerator href =“ https://developer.apple.com/documentation/uikit/uiimpactfeedbackgenerator/3183920-ImpactoccurredWithStrentss” rel =“ nofollow noreferrer”>“ nofollow noreferrer”> factionccurredwithsentsenty 强度。已记录的声明为(在Objective-C中):

- (void)impactOccurredWithIntensity:(CGFloat)intensity;

截至此问题时,链接的文档页面没有提供有关该intermenty参数的有效值范围的信息,以及什么效果价值具有。

(范围0到1?0到无穷大?其他一些最大值?允许负值吗?较大的值会产生更强烈的触觉反馈吗? “ https://developer.apple.com/documentation/uikit/uiimpactfeedbackstyle” rel =“ nofollow noreferrer“> uiimpactfeedBackstyle value ,例如uiimpactfeedbackstyleheheavyuiimpactfeedbackgenerator可以用

?这个问题,一个简单的 google搜索actighoccurredwithStrintsenty 没有任何有意义的结果页。

我的问题:强度参数的有效值范围是什么,ImpactoccurredWithStrentmenty方法以及该值有什么具体效果?

The iOS UIKit class UIImpactFeedbackGenerator, in iOS 13+, has an instance method impactOccurredWithIntensity, which takes a single CGFloat parameter, intensity. The documented declaration is (in Objective-C):

- (void)impactOccurredWithIntensity:(CGFloat)intensity;

As of the time of this question, the linked documentation page provides no information on what the valid range of values are for that intensity parameter, and what effect the value has.

(Is the range 0 to 1? 0 to infinity? Some other maximum? Are negative values permitted? Do larger values generate more intense haptic feedback? How does the intensity value interact with the various UIImpactFeedbackStyle values, such as UIImpactFeedbackStyleHeavy, that the UIImpactFeedbackGenerator can be initialized with?)

Also as of the time of this question, a simple Google search for impactOccurredWithIntensity yields no meaningful results beyond that linked Apple documentation page.

My question: What are the valid range of values for the intensity parameter of the impactOccurredWithIntensity method, and what specific effect does the value have?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

背叛残局 2025-02-19 18:38:10

强度参数是0.01.0之间的值,旨在表示影响力的力量。 (此方法的标题声明和文档既表示;每种冲击都会播放的触觉振动的体积/强度。

当您初始化影响反馈生成器时,您选择的样式旨在描述撞击中涉及的UI元素的物理属性,例如它们是轻,重,柔软的还是刚性的。 会影响发生冲击时播放的触觉波形的类型

样式uiimpactFeedGenerator初始化时烤入uiimpactFeedGenerator是因为style应在相同的UI元素的多个影响中保持一致。另一方面,强度是每个影响的参数,因为它通常是UI元素相撞时移动的速度的函数。

由您决定哪些参数最适合您的用例。选择如何将不同的冲击速度映射到标准化0.0-1.0 intense的范围是您可以定义的。最终,您需要在真实设备上进行实验并调整参数,以产生令人信服的体验,从而增加交互作用,而不会分散注意力。

The intensity parameter is a value between 0.0 and 1.0, which is intended to represent the force of the impact. (The header declaration and documentation for this method both indicate this; the documentation may have been updated since you asked the question originally.) In terms of how it affects the haptic output, you can think of intensity as the volume/strength of the haptic vibration that gets played for each impact.

When you initialize an impact feedback generator, the style you choose is intended to describe the physical attributes of the UI elements involved in the impact, for example whether they are light, heavy, soft, or rigid. The style affects the type of haptic waveform that is played when an impact occurs, for example whether the vibration is more of a quick sharp tap, a dull thud, etc.

The reason that the style is baked in to the UIImpactFeedbackGenerator when it is initialized is because the style should remain consistent across multiple impacts for the same UI elements. On the other hand, the intensity is a parameter for each impact, as it's generally a function of how fast the UI elements were moving when they collided.

It's up to you to determine which parameters work best for your use case. Choosing how to map different impact velocities to the normalized 0.0 - 1.0 range of intensity is something you get to define. Ultimately, you'll want to experiment and tune the parameters on a real device to produce a compelling experience that adds to the interaction, without being distracting.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文