案例:根据多点触控用图片来绘制路径 和 清除路径。
主要获取坐标 设置imageview的坐标。
视图默认不支持 多点触控:设置为支持多点触控:[self.view setMultipleTouchEnabled:YES];
1.循环创建imageView
4 - (
void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)
event
5 {
6 NSInteger i =
0;
7 for (UITouch *touch
in touches) {
8 UIImageView *imageview =
[[UIImageView alloc]initWithImage:self.imageData[i]];
9 CGPoint location =
[touch locationInView:self.view];
10 [imageview setCenter:location];
11 [self.view addSubview:imageview];
12 i++
;
13 }
14 }
2.清除self.view
isKindOfClass: 来判断是什么类型的控件。
1 [imageview setCenter:location];
2 [self.view addSubview:imageview];
3 i++
;
4 }
5 }
6
7 - (
void)clearView
8 {
9 for (UIImageView *imageView
in self.view.subviews) {
10
11 if ([imageView isKindOfClass:[UIImageView
class]]) {
12 [UIView animateWithDuration:
5.0f animations:^
{
13 [imageView setAlpha:
0.1f];
14 } completion:^
(BOOL finished) {
15 [imageView removeFromSuperview];
16 }] ;
17 }
18 }
19 }
转载于:https://www.cnblogs.com/zhjl/p/4232297.html
相关资源:数据结构—成绩单生成器