Aligning text vertically center in UITextView
问题 I am setting some attributed text to textview, and giving line. I am trying to set baseline alignment vertically center but unable to set that. How can I set the text vertically center in textview. 回答1: First add/remove an observer for the contentSize key value of the UITextView when the view is appeared/disappeared: override func viewWillAppear(animated: Bool) { super.viewWillAppear(animated) textView.addObserver(self, forKeyPath: "contentSize", options: NSKeyValueObservingOptions.New,