Слишком маленький курсор в TextView? - PullRequest
0 голосов
/ 30 мая 2018

У меня есть приложение для iOS.Когда пользователь нажимает на текстовое представление, курсор изначально очень мал.Вот как это выглядит:

enter image description here

Как только пользователь начинает печатать, курсор меняет размер и становится намного больше.Вот как это выглядит:

enter image description here

Как видите, курсор на втором изображении больше, чем курсор на первом изображении.Как сделать начальный курсор больше?Я хочу, чтобы он имел тот же размер, что и курсор, который появляется, когда пользователь начинает печатать.

Вот мой код:

class ViewController: UIViewController, UITableViewDataSource, UITableViewDelegate, UITextViewDelegate {

    @IBOutlet weak var userMessageTextView: UITextView!

    override func viewDidLoad() {
        super.viewDidLoad()

        self.userMessageTextView.delegate = self

        //Used to make the border of the TextView look the same as the border of a TextField
        userMessageTextView.layer.borderColor = UIColor(red: 0.9, green: 0.9, blue: 0.9, alpha: 1.0).cgColor
        userMessageTextView.layer.borderWidth = 1.0
        userMessageTextView.layer.cornerRadius = 5   
    }

    func textViewDidBeginEditing(_ textView: UITextView) {
        //Used to Make the Cursor appear somewhat centered in the TextView; Without this, the bottom of the cursor is lined up with the bottom edge of the TextView, so the cursor is not centered within the textView
        userMessageTextView.contentOffset.y = 4.0
    }
}
...