Возможно ли разделить изображение на области и по нажатию на каждую совершать какое-либо действие? В моем примере по нажатию на отдельные детали танка показывать соответствующие деталям названия. Может есть какие-то библиотеки с подобным решением? Спасибо
Разделение изображения на области
Artur
#1
agafon.aga
#2
https://developer.apple.com/documentation/uikit/uitapgesturerecognizer
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
let tapGesture = UITapGestureRecognizer(target: self, action: #selector(tapGestureAction(_:)))
view.addGestureRecognizer(tapGesture)
}
func tapGestureAction(_ tapGesture: UITapGestureRecognizer) {
let tappedLocationPoint = tapGesture.location(in: view)
print(tappedLocationPoint.x)
print(tappedLocationPoint.y)
// determining which area has been tapped based on what's the value of x and y
// you logic goes here...
// ...
}
}