How to make TextEdit untapable but scrollable in SwiftUI

  Kiến thức lập trình

I have a TextEditor, which is covered by another View in ZStack:

ZStack {
  TextEditor()
  MyView()
}

Now when I tap on MyView, my TextEditor received this tap and get focused. My goal is to process tap only in MyView.

One possible solution is to make TextEditor .disabled, but in this case it becomes unscrollable. Another option is to pass to TextEditor .constant data, but it anyway remains tapable and focusable.

I want to achieve this behaviour:

  • MyView process taps
  • TextEditor ignores taps and not focusing but remains scrollable

New contributor

MrSunshine is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Theme wordpress giá rẻ Theme wordpress giá rẻ Thiết kế website

LEAVE A COMMENT