Is it possible to assign an accessibility action to a UILabel?

前端 未结 5 1576
轻奢々
轻奢々 2021-01-18 19:32

In our current UI, next to certain labels, we have a help-tip button that when clicked, explains the details of what the label references. As such, VoiceOver identifies the

5条回答
  •  迷失自我
    2021-01-18 20:04

    Have your tried adding a UITapGestureRecognizer to the Labels?

    Something like :

    let tapGesture: UITapGestureRecognizer = UITapGestureRecognizer(target: self, action: "tapResponse:")
        tapGesture.numberOfTapsRequired = 1
        sampleLabel.userInteractionEnabled =  true
        sampleLabel.addGestureRecognizer(tapGesture)
    
    func tapResponse(recognizer: UITapGestureRecognizer) {
        print("tap")
    }
    

提交回复
热议问题