I want to make url links clickable inside TextView as well as making that text editable just as Notes app in iPhone.
here's what I attempted:
txtVw.dataDetectorTypes = UIDataDetectorTypes.link
txtVw.isSelectable = true
txtVw.isEditable = false. // this is set to false to make link text tappable
txtVw.linkTextAttributes = [.foregroundColor: UIColor.blue, .underlineStyle: NSUnderlineStyle.single.rawValue]
txtVw.isUserInteractionEnabled = true
txtVw.delegate = self
let descTap = UITapGestureRecognizer(target: self, action: #selector(textViewTapped))
descTap.numberOfTapsRequired = 1
txtVw.addGestureRecognizer(descTap)
@objc func textViewTapped(_: UITapGestureRecognizer) {
txtVw.dataDetectorTypes = []
txtVw.isEditable = true
txtVw.becomeFirstResponder()
}
Issue here is if I set isEditable property true, link is not formatted and remaining text if not editable. I want to achieve same things as we have in iPhone notes app. Have anyone come across this scenario? Any help would be appreciated.
First you need to have textView instead of Textfield. They apply below programmatic way for setting color or styling.
Now for Making it editable and clickable need to set from storyboard like: Just check
Editable,Selectableoptions.