i am trying text enter in textview right to left alignment but at that time textview starting position enter space not taking textview in swift
@IBOutlet weak var textview: UITextView! @IBOutlet weak var sampleTF: UITextField!
override func viewDidLoad() {
super.viewDidLoad()
textview.textAlignment = .right
textview.isScrollEnabled = true
textview.heightAnchor.constraint(equalToConstant: 52.0).isActive = true
textview.delegate = self
}
@IBAction func sampleButton(_ sender: Any) {
}
func textViewDidChange(_ textView: UITextView) {
let size = CGSize(width: textView.frame.width, height: 200)
let estimateSize = textView.sizeThatFits(size)
guard textView.contentSize.height < 100.0 else { textview.isScrollEnabled = true; return}
textview.isScrollEnabled = false
textview.constraints.forEach { (constriant) in
if constriant.firstAttribute == .height {
constriant.constant = estimateSize.height
}
}
}