Теперь вам просто нужно взять это место и добавить туда представление. Попробуйте обновить touchesBegan
, чтобы оно выглядело примерно так:
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
for touch in touches {
let location = touch.location(in: self.view)
xpoint = location.x
ypoint = location.y
//Initialize the view at the correct spot
//We set the view's frame by giving it an origin (that's the CGPoint we build from the x and y coordinates) and giving it a size, which can be anything really
let pointView = UIView(frame: CGRect(origin: CGPoint(x: xpoint, y: ypoint), size: CGSize(width: 25, height: 25))
//Round the view's corners so that it is a circle, not a square
view.layer.cornerRadius = 12.5
//Give the view a background color (in this case, blue)
view.backgroundColor = .blue
//Add the view as a subview of the current view controller's view
self.view.addSubview(view)
}
}