NSAttributedString click event in UILabel using swift

前端 未结 7 1893
感情败类
感情败类 2020-12-29 13:49

Suppose I have an AttributedString : \"Already have an account? Sign in!\". I am placing this String in UILabel. Now when a user clicks on \"Sign in!\", current viewControl

相关标签:
7条回答
  • 2020-12-29 14:33

    You can apply tapGesture to the label.

    Create tap gesture recognizer:

    let tapGesture = UITapGestureRecognizer(target: self, action: "YOUR_METHOD:")
    

    Add gesture recognizer to label:

    YOUR_LABEL.addGestureRecognizer(tapGesture)
    

    Perform your tasks in this method:

    func YOUR_METHOD(sender:UITapGestureRecognizer){
        // Perform your operations here.
    }
    
    0 讨论(0)
提交回复
热议问题