as

AKPickerView-Swift

A simple yet customizable horizontal picker view.

Showing:

Popularity

Downloads/wk

0

GitHub Stars

579

Maintenance

Last Commit

5yrs ago

Contributors

9

Package

Dependencies

0

License

MIT

Categories

Readme

AKPickerView

Screenshot Screenshot

A simple yet customizable horizontal picker view.

The Swift port of AKPickerView.

Works on iOS 7 and 8.

Installation

###CocoaPods: In your Podfile:

pod "AKPickerView-Swift"

And in your *.swift:

import AKPickerView_Swift

###Carthage: In your Cartfile:

github "Akkyie/AKPickerView-Swift"

And in your *.swift:

import AKPickerView

###Manual Install Add AKPickerView.swift into your Xcode project.

Usage

  1. Instantiate and set delegate and dataSource as you know,

    self.pickerView = AKPickerView(frame: <#frame#>)
    self.pickerView.delegate = self
    self.pickerView.dataSource = self
    
  2. then specify the number of items using AKPickerViewDataSource,

    func numberOfItemsInPickerView(pickerView: AKPickerView) -> Int {}
    
  3. and contents to be shown. You can use either texts or images:

    func pickerView(pickerView: AKPickerView, titleForItem item: Int) -> NSString {}
    // OR
    func pickerView(pickerView: AKPickerView, imageForItem item: Int) -> UIImage {}
    
  • Using both texts and images are currently not supported. When you implement both, titleForItem will be called and the other won't.
  • You currently cannot specify image sizes; AKPickerView shows the original image in its original size. Resize your images in advance if you need.
  1. You can change its appearance with properties below:

    var font: UIFont
    var highlightedFont: UIFont
    var textColor: UIColor
    var highlightedTextColor: UIColor
    var interitemSpacing: CGFloat
    var viewDepth: CGFloat
    var pickerViewStyle: AKPickerViewStyle
    
    • All cells are laid out depending on the largest font, so large differnce between the sizes of font and highlightedFont is NOT recommended.
    • viewDepth property affects the perspective distortion. A value near the screen's height or width is recommended.
  2. After all settings, never forget to reload your picker.

    self.pickerView.reloadData()
    
  3. Optional: You can use AKPickerViewDelegate methods to observe selection changes:

    func pickerView(pickerView: AKPickerView, didSelectItem item: Int) {}
    

    Additionally, you can also use UIScrollViewDelegate methods to observe scrolling.

For more detail, see the sample project.

Contact

@akkyie http://twitter.com/akkyie

License

MIT. See LICENSE.

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100