Giter Club home page Giter Club logo

akpickerview-swift's Introduction

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
  1. then specify the number of items using AKPickerViewDataSource,
func numberOfItemsInPickerView(pickerView: AKPickerView) -> Int {}
  1. 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.
  1. After all settings, never forget to reload your picker.
self.pickerView.reloadData()
  1. 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.

akpickerview-swift's People

Contributors

akkyie avatar anas10 avatar ferannor avatar josephkhawly avatar loicwolff avatar mats-claassen avatar pitsko avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.