【问题标题】:texteditor scroll hidden in swiftUIswiftUI中隐藏的texteditor滚动
【发布时间】:2022-11-10 09:57:39
【问题描述】:

我想在 textEditor 中隐藏滚动指示器。 swiftui 修饰符的支持,uikit 可能的方式在?

TextEditor(text: $context)
                        .foregroundColor(self.context == contextPlaceholder ? Color.grayA7 : Color.gray23)
                        .font(.bodyRegular)
                        .focused($isTextFieldsFocused)
                        .background(Color.grayF5)
                        .lineSpacing()
                        .padding(.vertical, 23)
                        .padding(.horizontal, 20)
                        .textSelection(.disabled)
                        .onTapGesture {
                            if self.context == contextPlaceholder{
                                self.context = ""
                            }
                        }

【问题讨论】:

    标签: swiftui text-editor


    【解决方案1】:

    使用Introspect

    TextEditor(text: $context)
        .introspectTextView { textView in
            textView.showsVerticalScrollIndicator = false
        }
    

    【讨论】:

    • 您必须添加import Introspect
    • 谢谢 !但是,我通过 swiftpm 收到并做了,但它不起作用。用 swiftpm 添加后有什么需要做的吗? notion.so/rriver2/4509811e84784653bf9d035ea9183a81
    • 复制并粘贴代码,然后你应该很高兴!
    • 请检查链接。 (我试过但它不起作用)
    • 忽略它,尝试运行
    【解决方案2】:

    если нужно, текстовый редактор скрыть индикаторы прокрутки в iOS 16 Swift 编写此代码 文本编辑器 (текст: $textEditor) .scrollIndicators(.hidden)

    【讨论】: