HomeiOS Developmentios - How can we make textual content selectable with swift? (...

ios – How can we make textual content selectable with swift? ( ReactNative View Module )


Hi I am making an attempt to create a local view in swift for use in React Naitve, and I need to create a selectable TextView.

I need to create one thing like the instance beneath.

enter image description here

To do that, I first wrote the code beneath.

import UIKit

  class SelectableTextView: UIView {
    override init (body: CGRect) {
      tremendous.init(body: body)
      setupView()
    }

    required init?(coder aDecoder: NSCoder) {
      tremendous.init(coder: aDecoder)
      setupView()
    }
      
    non-public func setupView() {
      self.addSubview(textField)
    }
    
    let textField: UITextField = {
      let subject = UITextField()
      subject.isEnabled = false
      
      subject.autoresizingMask = [.flexibleWidth, .flexibleHeight]
      return subject
    }()
    
    @objc func setValue(_ val: NSString) {
      textField.textual content = val as String?
    }
  }

Nonetheless, it does not reply to urgent the textual content. How can I make the textual content selectable when pressed?

I am not acquainted with swift, however I am making an attempt to create this out of necessity.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments