我有一个应用程序将数组中的点与线连接起来,接下来我要做的是为每条线的端点添加一个标记,为此我选择了一个红点。但我什至不知道如何开始。每次用户点击屏幕时,图像都应该出现,因为那是创建新点的时候。谢谢。
最佳答案
最简单的解决方案是添加 UITapGestureRecognizer
用下面的方法作为GR的 Action 来给你看。假设您正在为您的点使用例如图像 Assets ,它将是:
-(void)screenTapped:(UITapGestureRecognizer*)tap {
CGPoint tapLocation = [tap locationInView:self.view];
UIImageView *redDotImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"redDot"]];
redDotImageView.center = tapLocation;
[self.view addSubview:redDotImageView];
}
关于ios - 将图像添加到触摸位置 iOS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24493979/