触觉滑动条 3.0.0

触觉滑动条 3.0.0

Dale Price维护。



触觉滑动条

CI Status Version License Platform

一个设计用来轻松抓取和使用的滑动条控件,因为它可以从轨道上的任何位置拖动或轻触,类似于控制中心和应用集成的滑动条。因为这种类型的滑动条以图形方式表示对值的直接操作,所以应该用于实时调整可以实时观察到的值更改(例如声音 volume或灯光亮度)。

Animation of TactileSliders in various orientations being clicked and dragged in the iOS simulator, followed by a transition from light to dark appearance

特性

  • 可以拖动或可选点击来设置值
  • 支持水平和垂直方向,两种方向均可
  • IBDesignable – 在Interface Builder或编程中可自定义颜色、值、圆角和行为
  • 默认使用语义系统颜色支持浅色和深色外观(iOS 13+)
  • 可调整的触觉反馈(iOS 10+)
  • 支持VoiceOver
  • 在iPadOS上支持基于指针(例如触摸板或鼠标)的滚动(iOS 13.4+)

示例

要运行示例项目,请克隆仓库,然后首先从Example目录运行pod install

需求

支持iOS 8.0+

  • 要使用触觉反馈,需要iOS 10.0+
  • 要使用指针,需要iPadOS 13.4+

安装

TactileSlider可作为Swift包或通过CocoaPods获取。

要使用CocoaPods安装,只需将以下行添加到您的Podfile中

pod 'TactileSlider'

使用

let slider = TactileSlider(frame: someRect)

slider.minimumValue = 1
slider.maximumValue = 10

slider.setValue(3.8, animated: true)

设置方向和方向

slider.vertical = true
slider.reverseValueAxis = true

调整行为

slider.isContinuous = false
slider.enableTapping = false // allow or disallow tapping anywhere on the slider track to instantly set a value
slider.feedbackStyle = .medium // customize haptic feedback
slider.isScrollingEnabled = false // allow or disallow scrolling to adjust the slider using a connected pointing device on iPadOS

更改颜色和外观

slider.trackBackground = UIColor.black.withAlpha(0.8) // use translucent black for the slider track
slider.tintColor = UIColor.systemGreen // use dynamic green for the slider thumb
slider.cornerRadius = 12
slider.isPointerInteractionEnabled = true // display a hover effect when under the pointer on iPadOS

Interface Builder

screenshot of Xcode Interface Builder demonstrating a TactileSlider being customized using the graphical interface

作者

Dale Price (@[email protected])

许可协议

TactileSlider 在 MIT 许可证下可用。有关更多信息,请参阅 LICENSE 文件。