I have textView where user can write something and Label to display number of characters in textView. This is how i create my textView and label
var messageTextView: UITextView = {
let textView = UITextView()
return textView
}()
var messageTextViewTextCounterLabel: UILabel = {
let label = UILabel()
return label
}()
I have function to setup my label and uitextview.
let guide = self.view.safeAreaLayoutGuide
messageTextView.text = "Write something..:"
messageTextView.delegate = self
self.view.addSubview(messageTextView)
messageTextView.translatesAutoresizingMaskIntoConstraints = false
messageTextView.leadingAnchor.constraint(equalTo: guide.leadingAnchor, constant: 20).isActive = true
messageTextView.trailingAnchor.constraint(equalTo: guide.trailingAnchor, constant: -20).isActive = true
messageTextView.topAnchor.constraint(equalTo: guide.topAnchor, constant: 0).isActive = true
messageTextView.bottomAnchor.constraint(equalTo: guide.bottomAnchor, constant: -20).isActive = true
messageTextViewTextCounterLabel.text = "0/800"
self.messageTextView.addSubview(messageTextViewTextCounterLabel)
messageTextViewTextCounterLabel.translatesAutoresizingMaskIntoConstraints = false
messageTextViewTextCounterLabel.trailingAnchor.constraint(equalTo: messageTextView.leadingAnchor, constant: 0).isActive = true
messageTextViewTextCounterLabel.bottomAnchor.constraint(equalTo: messageTextView.bottomAnchor, constant: 0).isActive = true
messageTextViewTextCounterLabel.heightAnchor.constraint(equalToConstant: 15).isActive = true
I position my label to be inside my TextView. I want it to be in bottom-right corner, but the label appears in bottom-right of the text in my textView. [
How can i place my label inside textview to be in bottom-right corner? (NOT bottom-right of the text)