Giter Site home page Giter Site logo

sbpickerselector's Introduction

SBPickerSelector

easy framework to setup pickers in your iOS project, easy picker manager, now with swift compatibility

you can see how to works in the example project the file named "ViewController.swift" in the method showPickerAction

alt tag

Installation with CocoaPods

CocoaPods is a dependency manager for Objective-C and Swift, which automates and simplifies the process of using 3rd-party libraries like SBPickerSelector in your projects.

Podfile

platform :ios, '9.0'
pod 'SBPickerSelector'

Installation without CocoaPods

  • import in your project the folder "SBPickerSelector"

How to use

in the header of your file...

import SBPickerSwiftSelector

and just create an object SBPickerSwiftSelector with the params that you want.

  • picker modes:

    • text: just a list to select
    • dateDefault: date selection with full data(year, month, day, hour, minutes)
    • dateHour: just an option to select hour and minutes
    • dateDayMonthYear: option to select day, month and year
    • dateMonthYear: option to select just month and year
  • params:

    • mode: mode of the picker
    • data: an array of the datasource, can be [String] or [[String]], single string array will be display a list of 1 section with the list, array of array will display each array in a separate sections (just mandatory in mode .text)
    • startDate: min date for the date selection (ignored in mode: .text, default nil - year 1920)
    • endDate: max date for the date selection (ignored in mode: .text, default nil - year 2050)
    • defaultDate: default text displayed in the picker(ignored in mode: .text, default nil)

if you want to implement a cancel action just append the cancel method of the picker, and if you want to implement a set action just append the set method, this set method will return [Any] where will be [String] or [[String]] if it in .text mode and will be [Date] with only 1 date for the any of the date selection.

SBPickerSwiftSelector(mode: SBPickerSwiftSelector.Mode.dateHour, data: ["hi","there"], defaultDate: Date()).cancel {
            print("cancel, will be autodismissed")
            }.set { values in
                if let values = values as? [String] {
                    sender.setTitle(values[0], for: UIControl.State.normal)
                } else if let values = values as? [Date] {

                    let dateFormatter = DateFormatter()
                    dateFormatter.dateFormat = "YYYY-MM"
                    print(dateFormatter.string(from: values[0]))
                }

        }.present(into: self)

feedback?

sbpickerselector's People

Contributors

busta117 avatar dzamataev avatar klinkert0728 avatar bunn avatar juangdelvalle avatar

Watchers

James Cloos 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.