SwiftlySlider
一款简单的 iOS 滑块控件。
安装
CocoaPods:
pod 'SwiftlySlider'
手动:
Just copy the SwiftlySlider.swift into your project.
使用
您可以从 Storyboard 或 XIB 创建,或者手动创建。
let slider = SwiftlySlider()
为了处理值的改变,您应该实现协议 SwiftlySliderDelegate
slider.delegate = self func swiftlySliderValueChanged(value: Int) { }
方向
picker.direction = SwiftlySlider.PickerDirection.Horizontal // Vertical, Horizontal
您还可以更改当前值、最大值或最小值,例如
picker.currentValue = 0 picker.maxValue = 30 picker.minValue = 1
滑块设置
sliderImage // Custom image of the slider sliderImageOffset // Offset of custom slider position sliderSize // Size of custom slider position
示例
slider.sliderImage = UIImage(named: "CustomSlider") slider.sliderImageOffset = CGPoint(x: 0, y: -1) slider.sliderSize = CGSize(width: 30, height: 15)
普通指示器
useNormalIndicator // Use normal indicator normalValue // Normal value
颜色设置
labelFontColor // Font color of the moving label labelBackgroundColor // Background color of the moving label labelFont // Font of the moving label bgColor // Background color
您可以在本仓库中轻易找到示例。
许可证
SwiftlySlider 根据 MIT 许可证提供。有关更多信息,请参阅 LICENSE 文件。