WheelPicker 1.0.1

WheelPicker 1.0.1

Dima Hapichios.dev维护。



WheelPicker

Version Swift 3.0.x

TheMindStudios

一个简单且可定制的水平和垂直选择器视图

功能

  • 垂直或水平选择器
  • 图片或文本数据
  • 配置 UILabel & UIImageView
  • 平面 & 3D 风格
  • 自定义遮罩
  • 配置鱼眼因子

Example Example

使用方法

  1. WheelPicker 模块导入到您的 ViewController 类中
import WheelPicker
  1. 实例化并设置委托和数据源,如同您所知。如有需要,配置 WheelPicker
picker.dataSource = self
picker.delegate = self

2.1. 如有需要,配置 WheelPicker

picker.interitemSpacing = 25.0
picker.fisheyeFactor = 0.001
picker.style = .style3D
picker.isMaskDisabled = false
picker.scrollDirection = .vertical

picker.textColor = UIColor.blue.withAlphaComponent(0.5)
picker.highlightedTextColor = UIColor.blue
  1. 然后使用 WheelPicker 方法指定条目数量
func numberOfItems(_ wheelPicker: WheelPicker) -> Int
  1. 指定要显示的内容。您可以使用文本或图片
optional func titleFor(_ wheelPicker: WheelPicker, _ index: Int) -> String
optional func imageFor(_ wheelPicker: WheelPicker, _ index: Int) -> UIImage
func wheelPicker(_ wheelPicker: WheelPicker, configureLabel label: UILabel, at index: Int) {
   
   label.textColor = UIColor.black.withAlphaComponent(0.5)
   label.highlightedTextColor = UIColor.black
   label.backgroundColor = UIColor.init(hue: CGFloat(index)/CGFloat(flags.count) , saturation: 1.0, brightness: 1.0, alpha: 1.0)
}
  • 目前不支持同时使用文本和图片。当您实现两者时,titleFor(_ wheelPicker: WheelPicker, at index: Int) 将被调用,而另一个则不会。
  • 您目前不能指定图片大小;《code>WheelPicker 将以原大小显示原始图片。如果需要,请提前调整图片大小。
  1. 可选:您可以使用 WheelPicker 方法来观察选择更改
func wheelPicker(_ wheelPicker: WheelPicker, didSelectItemAt index: Int)

CocoaPods 进行安装

要通过 CocoaPods 安装,请将以下行添加到您的 Podfile 中。您需要 CocoaPods 版本 1.1.0 或更高版本

$ gem install cocoapods

Podfile

要使用 CocoaPods 将 WheelPicker 综合到您的 Xcode 项目中,请在您的 Podfile 中指定它

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '9.0'
use_frameworks!

target 'TargetName' do
  pod 'WheelPicker', '~> 1.0'
end

然后,运行以下命令

$ pod install

许可

WheelPicker 采用 MIT 许可证。有关更多信息,请参阅 LICENSE 文件。