Giter Site home page Giter Site logo

drawview's Introduction

DrawView

Subclass of UIView that supports drawing.

Basic Usage

Using CocoaPods

pod "DrawView"

In the storyboard under the views Identity Inspector set the view class to DrawView.

In the implementation file you can setup the drawing view.

drawingView.strokeColor = [UIColor blackColor];
drawingView.strokeWidth = 25.0f;

Since DrawView is a subclass of UIView, to change the background just change the backgroundColor property.

Usage

Drawing Existing Paths

You can draw either a existing UIBezierPath or CGPathRef by calling either of the following methods.

- (void)drawBezier:(UIBezierPath *)path;
- (void)drawPath:(CGPathRef)path;

Animating Path

To animate the current path in the draw view call

- (void)animatePath;

Undo Support

To support undo add a button with a target to the DrawView instance, and set the action to undoDrawing:. See example for more details.

Signature Mode

To enable signature mode call setMode: and pass in the SignatureMode mode type. This will give you a simple signature UI for the user to use while signing on the device.

Reading Drawing View

There are two ways to read what is currently in the drawing view. Either call imageRepresentation which will return a UIImage that can be later used in a email or to save to the users Camera Roll. Or call bezierPathRepresentation which returns a single bezier path that can be archived and restored within your app. See the example project for more information.

		// How to read the drawing view into a image and save to the camera roll.
        UIImage *drawingImage = [drawingView imageRepresentation];
        ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
        [library writeImageToSavedPhotosAlbum:drawingImage.CGImage orientation:ALAssetOrientationUp completionBlock:^(NSURL *assetURL, NSError *error) {
            NSLog(@"%@",assetURL);
            NSLog(@"%@",error);
        }];

Debugging Drawing

To debug the path set debugBox to true. This will add a grey box around the bounds of the current path.

drawview's People

Contributors

fmscode 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.