zoukankan      html  css  js  c++  java
  • 简单的画板

    #import "MyView.h"
    @interface MyView ()
    {
        CGMutablePathRef pathRef;
    }
    @end
    @implementation MyView
    -(id)initWithCoder:(NSCoder *)aDecoder
    {
        if (self=[super initWithCoder:aDecoder])
        {
            pathRef=CGPathCreateMutable();
           
        }
        return self;
        
    }
    -(void)drawRect:(CGRect)rect
    {
        CGContextRef contextRef=UIGraphicsGetCurrentContext();
        CGContextAddPath(contextRef, pathRef);
        CGContextStrokePath(contextRef);
        
    }
    -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
    {
        CGPoint p=[touches.anyObject locationInView:self];
        CGPathMoveToPoint(pathRef, nil, p.x, p.y);
        
    }
    -(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
    {
        CGPoint p=[touches.anyObject locationInView:self];
        CGPathAddLineToPoint(pathRef, nil, p.x, p.y);
        [self setNeedsDisplay];
    }
    @end
  • 相关阅读:
    毕设进度21
    毕设进度20
    Javascript高级程序设计第三版-笔记
    前端踩过的坑
    thinkphp笔记
    PHP 发邮件《转》
    smarty笔记
    jquery笔记
    JS笔记
    php万年历
  • 原文地址:https://www.cnblogs.com/thbbsky/p/4382411.html
Copyright © 2011-2022 走看看