【发布时间】:2020-07-31 20:24:12
【问题描述】:
我在项目中使用 UITextView,我需要它只能向下滚动(不能向上滚动)。有没有办法可以相对容易地做到这一点?如果不是,我可能会继承 UIScrollView 或一些奇怪的东西,但我真的不想这样做。
这是我的基本 UIViewRepresentable 结构
struct TextView: UIViewRepresentable {
typealias UIViewType = UITextView
var configuration = { (view: UIViewType) in }
func makeUIView(context: UIViewRepresentableContext<Self>) -> UIViewType {
let view = UIViewType()
view.isEditable = false
return view
}
func updateUIView(_ uiView: UIViewType, context: UIViewRepresentableContext<Self>) {
configuration(uiView)
}
}
谢谢!
【问题讨论】: