Create a class which is a subclass of UIView... then add these lines of code in tat...
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [touches anyObject];
gestureStartPoint = [touch locationInView:self];
[currentPath moveToPoint:(gestureStartPoint)];
}
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [touches anyObject];
currentPosition = [touch locationInView:self];
[currentPath addLineToPoint:(currentPosition)];
[self setNeedsDisplay];
}
- (void)drawRect:(CGRect)rect {
[[UIColor redColor] set];
[currentPath strokeWithBlendMode:kCGBlendModeNormal alpha:1.0];
}
in the header file declare the following.....
CGPoint gestureStartPoint,currentPosition;
UIBezierPath *currentPath;
and declare a property...
@property(nonatomic,retain)UIBezierPath *currentPath;
in the initWIthFrame method inside if block add these lines
currentPath = [[UIBezierPath alloc]init];
currentPath.lineWidth=3;
Create a viewcontroler class then add these lines of code in loadVIew method..
mainView=[[sampleView alloc]initWithFrame:CGRectMake(0, 0, 320, 480)];
mainView.backgroundColor=[UIColor whiteColor];
self.view=mainView;
where sampleView is the UIView subclass u created b4....
Hope this helps...