Skip to content
This repository has been archived by the owner. It is now read-only.
A simple yet customizable horizontal picker view.
Objective-C Ruby Makefile
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
AKPickerViewSample.xcodeproj Fixed glitch when user dragged beyond the edge Apr 7, 2015
AKPickerViewSample Fixed #62 UICollectionViewFlowLayout cache mismatched frame (iOS9, xC… Nov 16, 2015
.travis.yml Added Makefile and updated .travis.yml Nov 26, 2014
AKPickerView.podspec Updated podspec Nov 18, 2015
LICENSE Add README and LICENSE Apr 7, 2014
Makefile Updated .travis.yml Nov 26, 2014
README.md Updated README.md Jan 29, 2015
Screenshot.gif
Screenshot2.gif Added missing screenshot Dec 11, 2014

README.md

AKPickerView

Build Status Gitter

Screenshot

Screenshot

A simple yet customizable horizontal picker view.

Works on iOS 6, 7 and 8.

News: Say Good-Bye to Bridging-Header! The Swift version is here.

Installation

Use CocoaPods

pod "AKPickerView"

…or simply add AKPickerView.h/m into your project.

Usage

Caveat: From version 2.0, dataSource separated from delegate. When you updated it, check new how to use below.

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

    self.pickerView = [[AKPickerView alloc] initWithFrame:<#frame#>];
    self.pickerView.delegate = self;
    self.pickerView.dataSource = self;
  2. then specify the number of items using AKPickerViewDataSource methods,

    - (NSUInteger)numberOfItemsInPickerView:(AKPickerView *)pickerView;
  3. and specify contents to be shown. You can use either texts or images:

    - (NSString *)pickerView:(AKPickerView *)pickerView titleForItem:(NSInteger)item;
    // OR
    - (UIImage *)pickerView:(AKPickerView *)pickerView imageForItem:(NSInteger)item;
    • Using both texts and images are currently not supported. When you implement both, -pickerView: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.
  4. You can change its appearance with properties below.

    @property (nonatomic, strong) UIFont *font;
    @property (nonatomic, strong) UIFont *highlightedFont;
    @property (nonatomic, strong) UIColor *textColor;
    @property (nonatomic, strong) UIColor *highlightedTextColor;
    @property (nonatomic, assign) CGFloat interitemSpacing;
    @property (nonatomic, assign) CGFloat fisheyeFactor;
    • All cells are laid out depending on the largest font, so large differnce between the sizes of font and highlightedFont is NOT recommended.
    • fisheyeFactor property affects perspective distortion. The range is 0.0 - 1.0; slight value such as 0.0001 is recommended.
  5. After all settings, never forget to reload your picker.

    [self.pickerView reloadData];
  6. Optional: You can use AKPickerViewDelegate method to observe selection changes:

    - (void)pickerView:(AKPickerView *)pickerView didSelectItem:(NSInteger)item;

    Additionally, you can use UIScrollViewDelegate method to observe scrolling.

For more detail, see the sample project.

Contact

@akkyie http://twitter.com/akkyie

License

MIT. See LICENSE.

You can’t perform that action at this time.