Coder Social home page Coder Social logo

besttumi / swiftypickerpopover Goto Github PK

View Code? Open in Web Editor NEW

This project forked from hsylife/swiftypickerpopover

0.0 2.0 0.0 379 KB

Popover with Picker by Swift 3/2.3 for iPhone/iPad, iOS9+.

License: MIT License

Swift 96.00% Ruby 2.19% Objective-C 1.80%

swiftypickerpopover's Introduction

SwiftyPickerPopover

Popover with Picker by Swift 3 for iPhone/iPad, iOS9+.

Version License Platform Carthage compatible

Features

  • Popover with Picker which can be chosen from several types, appears on iPhone or iPad.
  • Swift 3, iOS9+. UIPopoverController free.
  • Callback

Required

  • Swift 3, Xcode 8. (If you want to use it on Swift 2.3, please check up SwiftyPickerPopover 1.3)
  • iOS 9+
  • CocoaPods 1.1.0.rc.2+ or Carthage 0.12.0+

License

MIT.

Screenshots

Usage

For Installing it on Swift 3 with CocoaPods, specify it in your 'Podfile'.

platform :ios, '9.0'
use_frameworks!
pod 'SwiftyPickerPopover'

If you want to use it on Swift 2.3, specify it.

pod 'SwiftyPickerPopover ~> '1.3.0'

Run 'pod install'.

For Installing with Carthage, add it to your Cartfile.

github "hsylife/SwiftyPickerPopover"

Run 'carthage update --platform iOS'.

On Xcode, import the module.

import SwiftyPickerPopover

Basic

DatePickerPopover appears.

DatePickerPopover.appearFrom(
 originView: button,
 baseViewController: self,
 title: "DatePicker",
 dateMode: .Date,
 initialDate: NSDate(),
 doneAction: { selectedDate in print("selectedDate \(selectedDate)")},
 cancelAction: {print("cancel")}
)

StringPickerPopover appears.

StringPickerPopover.appearFrom(
 originView: button,
 baseViewController: self,
 title: "StringPicker",
 choices: ["value 1","value 2","value 3"],
 initialRow:0,
 doneAction: { selectedRow, selectedString in print("done row \(selectedRow) \(selectedString)")} ,
 cancelAction: { print("cancel")}
)

ColumnStringPickerPopover which has variable multiple components, appers.

ColumnStringPickerPopover.appearFrom(
 originView: button,
 baseViewController: self, title: "Columns Strings",
 choices: [["Breakfast", "Lunch", "Dinner"], ["Tacos", "Sushi", "Steak", "Waffles", "Burgers"]],
 initialRow: [0,0],
 columnPercent: [0.5, 0.5],
 fontSize: 12.0,
 doneAction: { selectedRows, selectedStrings in print("selected rows \(selectedRows) strings \(selectedStrings)")}, 
 cancelAction: {print("cancel")}
)

CountdownPickerPopover which returns interval time, appears.

CountdownPickerPopover.appearFrom(
 originView: sender,
 baseViewController: self,
 title: "CountdownPicker",
 dateMode: .countDownTimer,
 initialInterval: TimeInterval(),
 doneAction: { timeInterval in print("timeInterval \(timeInterval)")},
 cancelAction: {print("cancel")}
)

Advanced

DatePickerPopover with clearAction

DatePickerPopover.appearFrom(originView: button,
  baseViewController: self,
  title: "Clearable DatePicker",
  dateMode: .Date,
  initialDate: NSDate(),
  doneAction: { selectedDate in print("selectedDate \(selectedDate)")},
  cancelAction: {print("cancel")},
  clearAction: { print("clear")}
)

StringPickerPopover with displayStringFor

let displayStringFor:((String?)->String?)? = { string in
   if let s = string {
      switch(s){
      case "value 1":
        return "😊"
      case "value 2":
         return "😏"
      case "value 3":
         return "πŸ˜“"
      default:
         return s
      }
    }
  return nil
  }
        
StringPickerPopover.appearFrom(
  originView: button,
  baseViewController: self,
  title: "StringPicker",
  choices: ["value 1","value 2","value 3"],
  displayStringFor: displayStringFor,
  initialRow:0,
  doneAction: { selectedRow, selectedString in print("done row \(selectedRow) \(selectedString)")},
  cancelAction: { print("cancel")}
)

StringPickerPopover appears from CollectionView's cell.

func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
 let theCell = collectionView.dequeueReusableCell(withReuseIdentifier: "Cell", for: indexPath)
 StringPickerPopover.appearFrom(
   originView: theCell,
   baseView: collectionView,
   baseViewController: self,
   title: "CollectionView",
   choices: ["value 1","value 2","value 3"],
   initialRow:0,
   doneAction: { selectedRow, selectedString in print("done row \(selectedRow) \(selectedString)")},
   cancelAction: { print("cancel")})
}

Contributors

Ken Torimaru GitHub for CountdownPickerPopover and ColumnStringPickerPopover.

BalestraPatrick GitHub

Author

Yuta Hoshino Twitter Facebook

swiftypickerpopover's People

Contributors

hsylife avatar ktorimaru avatar balestrapatrick avatar

Watchers

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