Answer the question
In order to leave comments, you need to log in
How to make gesture on UILabel?
Can you suggest, plz
Need to add "Tap" gesture to UIlabel.
If the gesture is added to fieldView, everything works, but it doesn't work on elem1.
What could be the problem?
fieldView - there I draw a field using func draw(_ rect: CGRect) {...}
import UIKit
class ViewController: UIViewController {
var ticTac = TicTacToeModel()
@IBOutlet weak var fieldView: FieldView!
@IBOutlet weak var elem1: UILabel! {
didSet {
let tapGesture = UITapGestureRecognizer(target: self, action: #selector(self.taplabel))
elem1.addGestureRecognizer(tapGesture)
}
}
override func viewDidLoad() {
super.viewDidLoad()
}
func taplabel() {
elem1.text = ticTac.stepPlayer()
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question