Code Monkey home page Code Monkey logo

smoothpicker's Introduction

SmoothPicker

Version License Platform

A Customized Component for creating a horizontal iOS picker with custom views

Alt Text Alt Text Alt Text

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Installation

SmoothPicker is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'SmoothPicker'

Usage

Create the view either by storyboard or by frame

class ViewController{
   @IBOutlet weak var pickerView: SmoothPickerView!
    
    var i = 0
    var views = [UIView]()
    override func viewDidLoad() {
        super.viewDidLoad()
        for _ in 1..<11 {
            let view = UIView(frame: CGRect(x: 0, y: 0, width: 50, height: 50))
            view.backgroundColor = UIColor.gray
            views.append(view)
        }
        
        pickerView.firstselectedItem = 2 // you can also set the first selected item at launch 

    }
    func didSelectIndex(index: Int) {
        print("SelectedIndex \(index)")
    }   
    func numberOfItems() -> Int {
        return 10
    }
    
    func itemForIndex(index: Int) -> UIView {
        return views[index]
    }
    @IBAction func navigateNext(_ sender: Any) {
        pickerView.navigate(direction: .next)
    }
    @IBAction func navigatePervious(_ sender: Any) {
        pickerView.navigate(direction: .pervious)
    }
}

Data Source

func numberOfItems() -> Int //number of items to display
func itemForIndex(index:Int) -> UIView // retrun the view per item just make sure it can calculate it's frame correctly 

Delegate

 func didSelectIndex(index:Int,view:UIView) // the selected item  

Navigation

//The default navigation is swipe you can in addtion set navigation to some button 
public enum Direction {
    case  next
    case  pervious
}
public func navigate(direction :Direction)

Selection

open var firstselectedItem = 0 // to set the first selected item at intilization 0 is the default 

Customization

Alt Text

// you can choose between the selection styles available 
// a new styles and layouts are upcoming 
public enum SelectionStyle {
    case scale
    case colored
}
SmoothPickerConfiguration.setSelectionStyle(selectionStyle: .scale) // scale is deafult default 
static func setColors(selectedColor:UIColor,dimmedColor:UIColor) // for colred selection style black and gray is default
@objc open func setSmoothSelected(_ selected : Bool) // you can ovveride it in your view it gives you the. current state of your view 

Authors

License

SmoothPicker is available under the MIT license. See the LICENSE file for more info.

thanks for this tutorial it was a great help https://medium.com/@shaibalassiano/tutorial-horizontal-uicollectionview-with-paging-9421b479ee94

smoothpicker's People

Contributors

ahmednassersh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  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

smoothpicker's Issues

Compiling for iOS 9.0, but module 'SnapKit' has a minimum deployment target of iOS 10.0

I'm unable to build, and I cannot find where this error is really as my project settings are "Deployment target 12.0"

/.../Pods/SmoothPicker/SmoothPicker/Classes/SmoothPickerCollectionViewCell.swift:11:8:` Compiling for iOS 9.0, but module 'SnapKit' has a minimum deployment target of iOS 10.0: /.../Build/Products/Debug-iphonesimulator/SnapKit/SnapKit.framework/Modules/SnapKit.swiftmodule/x86_64.swiftmodule

How does it work?

I just wondered I can get it to work? (Using Swift 5) Some more documentation would be helpful.

  • The example cannot compile due to "No such module Snapkit" (I've run pod install and followed the instructions as best as I can)
  • The documentation doesn't help much. The code from the example is different from the example in readme, cannot get either to work at all
  • Using the example from the readme returns "Thread 1: EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)" on line 57 in SmoothPickerView.swift
  • Is SmoothPicker a subclass of UIView or UIViewPicker? What controller should I create in the storyboard?

error: IB Designables: Failed to render and update auto layout status for viewController

I dunno how to get past this error

error: IB Designables: Failed to render and update auto layout status for viewController (p8a-7o-nrR): dlopen(SmoothPicker.framework, 1): Library not loaded: @rpath/SnapKit.framework/SnapKit
  Referenced from: SmoothPicker.framework
  Reason: image not found
.../Base.lproj/Main.storyboard: error: IB Designables: Failed to render and update auto layout status for viewController (p8a-7o-nrR): The agent crashed

Example does not work

  1. Running "pod install" as instructed in the readme

Analyzing dependencies
Fetching podspec for SmoothPicker from ../
Downloading dependencies
Installing SmoothPicker 1.1.2 (was 1.1.1)
Using SnapKit (4.2.0)
Generating Pods project
Integrating client project
Sending stats
Pod installation complete! There is 1 dependency from the Podfile and 2 total pods installed.

This results in two errors when trying to build the project
SmoothPicker_Example
/SmoothPicker/SmoothPicker-1.1.2/Example/SmoothPicker/views.swift:10:8: No such module 'SnapKit'

SmoothPicker_Tests
/SmoothPicker/SmoothPicker-1.1.2/Example/Tests/Tests.swift:2:8: No such module 'SmoothPicker'

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.