当前位置: 代码迷 >> Iphone >> IOS 自定义View 在上面如何画路径
  详细解决方案

IOS 自定义View 在上面如何画路径

热度:70   发布时间:2016-04-25 06:45:19.0
IOS 自定义View 在上面怎么画路径
刚学ios 开发,之前搞android,我想在View上面绘制路径,按照我的手的滑动路径,目前只能是画一个直线,请大家指导下,API还不熟悉,谢谢了

------解决方案--------------------
LZ可以用UIBezierPath这个类。
具体使用的话可以这样:
C/C++ code
-(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];    }
  相关解决方案