Giter VIP home page Giter VIP logo

drawableview's Introduction

DrawableView

A UIView subclass that allows the user to draw on it.

Swift Version License Carthage compatible CocoaPods Compatible
Platform PRs Welcome

Add a DrawableView to your app and you will immediately be able to draw on it. Then try changing the stroke color, width, and transparency!

Features

  • Stroke Color
  • Stroke Width
  • Stroke Transparency
  • Undo
  • DrawableViewDelegate
  • Quad Curve Interpolation

Requirements

  • iOS 9.0+
  • Xcode 8.3.1

Installation

CocoaPods

You can use CocoaPods to install DrawableView by adding it to your Podfile:

pod 'DrawableView'

Simply import DrawableView wherever you would like to use it.

import UIKit
import DrawableView

Carthage

Create a Cartfile that lists the framework and run carthage update. Follow the instructions to add $(SRCROOT)/Carthage/Build/iOS/DrawableView.framework to an iOS project.

github "EthanSchatzline/DrawableView"

Usage example

class ViewController: UIViewController, DrawableViewDelegate {

    @IBOutlet var drawableView: DrawableView! {
      didSet {
        drawableView.delegate = self
        drawableView.strokeColor = .blue
        drawableView.strokeWidth = 12.0
        drawableView.transparency = 1.0
      }
    }

    func setDrawing(_ isDrawing: Bool) {
        /*
        Run some logic based on if the user is currently drawing a stroke or not.
        Commonly people hide the drawing tools UI while the user is drawing and fade it back in once they stop.
        */
    }

    func saveDrawingToPhotoLibrary() {
      guard let drawnImage = drawableView.image else { return }
      UIImageWriteToSavedPhotosAlbum(drawnImage, self, nil, nil)
    }
}

Contribute

We would love for you to contribute to DrawableView, check the LICENSE file for more info.

Meta

Ethan Schatzline โ€“ @_Easy_E โ€“ [email protected]

Distributed under the MIT license. See LICENSE for more information.

https://github.com/EthansShatzline/

drawableview's People

Contributors

ethanschatzline avatar keitaito avatar shrolr 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.