February 2014
Intermediate to advanced
560 pages
18h 58m
English
A line is defined by two points. Your BNRLine stores these points as properties named begin and end. When a touch begins, you will create a line and set both begin and end to the point where the touch began. When the touch moves, you will update end. When the touch ends, you will have your complete line.
In BNRDrawView.m, implement touchesBegan:withEvent: to create a new line.
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { UITouch *t = [touches anyObject]; // Get location of the touch in view's coordinate system CGPoint location = [t locationInView:self]; self.currentLine = [[BNRLine alloc] init]; self.currentLine.begin = location; self.currentLine.end = location; [self setNeedsDisplay]; ...Read now
Unlock full access