Giter Site home page Giter Site logo

zwgraphicview's Introduction

ZWGraphicView

签名涂鸦画板

功能

实际开发中主要用于手写签名及其它绘画涂鸦,最终生成图片,用于上传服务器。

文件结构

ZWGraphicView.h 和 ZWGraphicView.m两个文件。 ZWGraphicView.h的代码如下:

@interface ZWGraphicView : UIView
{
    CGPoint _start;//起始点
    CGPoint _move;//移动点
    CGMutablePathRef _path;//路径
    NSMutableArray * _pathArray;//保存路径信息
    CGFloat _lineWidth;//线宽
    UIColor * _lineColor;//线的颜色
    BOOL _isDrawLine;//是否有画线
}

/**
 *  线宽
 */
@property (nonatomic,assign) CGFloat  lineWidth;
/**
 *  线的颜色
 */
@property (nonatomic,strong) UIColor * lineColor;
/**
 *  画线路径
 */
@property (nonatomic,strong) NSMutableArray * pathArray;

/**
 *  获取画图
 */
-(UIImage*)getDrawingImg;

/**
 *  清空画板
 */
-(void)clearDrawBoard;

/**
 *  撤销上一次操作
 */
-(void)undoLastDraw;

/**
 *  保存图像至相册
 */
-(void)savePhotoToAlbum;

用法

#import "ZWGraphicView.h"引入头文件

- (void)viewDidLoad {
    [super viewDidLoad];
    
    ZWGraphicView * drawView = [[ZWGraphicView alloc] initWithFrame:CGRectMake(0, 100, self.view.bounds.size.width, self.view.bounds.size.height-100)];
    self.graphicView = drawView;
    [self.view addSubview:drawView];
   

}
- (IBAction)savePhoto:(id)sender {
    
    [self.graphicView savePhotoToAlbum];
}

- (IBAction)undo:(id)sender {
    
    [self.graphicView undoLastDraw];
}

- (IBAction)clearAll:(id)sender {
    
    [self.graphicView clearDrawBoard];
}

演示效果

image

zwgraphicview's People

Contributors

xzwgithub avatar xzwios avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 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.