Code Monkey home page Code Monkey logo

ios_swift_colorpicker's Introduction

iOS ColorPicker

Written completely in Swift.

ColorPicker ScreenShot

Overview

The Color Picker constist of a SwiftColorView and a SwiftColorPickerViewController. By Tapping or panning on the view the SwiftColorPickerDelegate is notfied about the changed color.

To customize the colors displayed by the SwiftColorPickerViewController implement the SwiftColorPickerDataSource protocoll and the caller class as the dataSource of the SwiftColorPickerViewController.

In the Repository are two Example projects, which show how to utilize the SwiftColorPickerViewController.

  • Using the ViewController in a storyboard
  • Creating and using the ViewController programmatically

The SwiftColorViewis @IBDesignableso it will render nicely in InterfaceBuilder.

SwiftColorView in InterfaceBuilder

Usage

Copy the SwiftColorPickerViewController.swiftinto your project.

Add ViewController in a Storyboard

  • Add a View Controller
  • Set View Class to SwiftColorPickerViewController
  • Select View and set Class of View to SwiftColorView

https://www.youtube.com/watch?v=VtV5bI_UBo4

You can change the porpertis of the SwiftColorViewin the inspector.

Add ViewController Programmatically

  • Instantiate a picker object
  • add a delegate

let colorPickerVC = SwiftColorPickerViewController()

colorPickerVC.delegate = self

  • (optional) add a dataSource

colorPickerVC.dataSource = self

Parameters:

  • Number of color blocks in x-direction. Color palette size is numberColorsInXDirection * numberColorsInYDirection

    colorPickerVC.numberColorsInXDirection = 20;

  • Number of color blocks in y-direction. Color palette size is numberColorsInXDirection * numberColorsInYDirection

    colorPickerVC.numberColorsInYDirection = 20;

  • Width of the edge around the color palette. The border change the color with the selection by the user. Default is 10

    colorPickerVC.coloredBorderWidth = 10;

  • Diameter of the circular view, which preview the color selection. The preview will apear at the fimnger tip of the users touch and show se current selected color.

    colorPickerVC.colorPreviewDiameter = 44;

More

If you like the code write me.

ios_swift_colorpicker's People

Contributors

christian1313 avatar hkalexling avatar

Watchers

 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.