简易涂鸦板

(一)简易涂鸦板

关于简易涂鸦板的制作 ,这也是响应者链事件的一种体现 。

主要 Touch 和 Event 的 结合

编程思路 : 大数组里面套着一个小数组 ,等同于大数组存的 是 一条条笔画 , 小数组是无数点得 集合 

主要在UIView 中实现方法:

画图所执行的方法

-(void)drawRect:(CGRect)rect

1、手指开始触摸屏幕的时候所执行的 方法

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event

{

}

2、手指开始移动的时候所执行的方法

-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event

{

}

3、手指触摸结束的时候所执行的方法

-(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event

{

 }

4、手指取消触摸屏幕的时候所执行的方法

-(void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event{

    

}

一般需要在-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event 重新调用 

[self setNeedsDisplay] 才可以 不断的 调用 DrawRect 方法实现 画图

 

以下 是实现多颜色画笔程序截图

 

 

 

posted on 2015-04-29 10:56  Allen丶LAS  阅读(94)  评论(0编辑  收藏  举报

导航