使用UITextView时,进入页面时不能够滚动,但是输入文字换行后可以滚动,解决方法
override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? {
let str = self.textView.text
let h = str.boundingRect(with: size, options: .usesLineFragmentOrigin, attributes: attributes, context:nil).size.height
self.textView.contentSize = CGSize(width: 0, height: h!+5)
return super.hitTest(point, with: event)
}
网友评论