David B. Levi (https://github.com/dblapps)
DAScratchPad is a small UIView subclass that provides a simple drawing interface. You can put this view anywhere in your UI, and your user can draw in it. You can add UI controls to change drawing color, link width, and opacity. You can also get the current image from the scratch pad, clear the current image, or replace the current image.
An example xcode project is included that demonstrates simple usage.
DAScratchPad is compatible with iOS4.3+.
DAScratchPad is available under the MIT license. See the LICENSE file for more info.
Copy the contents of the DAScratchPad directory to your xcode project.
Import DAScratchPad.h in appropriate places.
Add the QuartzCore frameworks to your project.
Add instance of DAScratchPad in interface builder, or add them programatically:
DAScratchPad* scratchpad = [[DAScratchPad alloc] initWithFrame:CGRectMake(30.0f, 30.0f, 150.0f, 150.0f)];
[self.view addSubview:scratchpad];
Change properties to control color, line width, and opacity:
scratchpad.drawColor = [UIColor greenColor];
scratchpad.drawWidth = 15.0f;
scratchpad.drawOpacity = 0.5f;
Use 'getSketch' to retrieve the current image:
UIImage* sketch = [scratchpad getSketch];
Use 'setSketch:' to replace the current image:
UIImage* image = [UIImage imageNamed:@"SavedImage.jpg"];
[scratchpad setSketch:image];
Use 'clearToColor:' to clear the current image:
[scratchpad clearToColor:[UIColor whiteColor]];