首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > Iphone >

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

2012-04-08 
IOS 自定义View在上面怎么画路径刚学ios 开发,之前搞android,我想在View上面绘制路径,按照我的手的滑动路

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];    } 

热点排行