Sunday, December 8, 2013

IOS Custom View how to draw a path in the above

Just learning ios development, before engaging in android, I want to draw a path in View the above, according to the sliding path of my hand, can only be to draw a straight line, please, under the guidance, API is not familiar with, thank you
Reply:
LZ can UIBezierPath this category.
Use specific words can do:
 
- (Void) touchesBegan: (NSSet *) touches withEvent: (UIEvent *) event {
UITouch * touch = [touches anyObject];
self.currentPath = [UIBezierPath bezierPath];
currentPath.lineWidth = 10.0;
[CurrentPath moveToPoint: [touch locationInView: self]];
[Paths addObject: self.currentPath];
}

- (Void) touchesMoved: (NSSet *) touches withEvent: (UIEvent *) event {
UITouch * touch = [touches anyObject];
[Self.currentPath addLineToPoint: [touch locationInView: self]];
[Self setNeedsDisplay];
}

- (Void) touchesEnded: (NSSet *) touches withEvent: (UIEvent *) event {
UITouch * touch = [touches anyObject];

for (UIBezierPath * path in paths) {
[Path removeAllPoints];
}


Reply:
TouchEnd above method in the removeAllPoints, the landlord does not have to write. This is what I use to own.

Reply:
Thanks for the answer, UIBezierPath is how to instantiate it? And I want to see the contents of the next drawRect function, thank you.
Reply:
Saw [UIBezierPath bezierPath];

Reply:
Learning,
To the point of it,

No comments:

Post a Comment