【问题标题】:SwiftUI: UITextField like propertiesSwiftUI:类似 UITextField 的属性
【发布时间】:2019-07-22 21:57:20
【问题描述】:

有谁知道如何自定义 SwiftUI TextField 属性,例如 spellCheckingType 或 autocorrectionType? 在不与 UIKit 交互的情况下做到这一点似乎是不可能的......

谢谢大家!

【问题讨论】:

    标签: swift textfield swiftui


    【解决方案1】:

    对于TextField或Text的AutoCorrection,你可以试试

    struct ContentView: View {
    
        @State private var name: String = "Angie"
        var body: some View {
    
                VStack {
                    TextField("Enter your name", text: $name)
                    Text("Hello, \(name)!")
                }
                .disableAutocorrection(true)
        }
    }
    

    我不确定 SwiftUI 中的拼写检查,但您可以查看 https://developer.apple.com/documentation/swiftui/textfield 进行修改。

    希望对您自定义TextField有所帮助!

    谢谢!!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-02-17
      • 2013-09-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-11-21
      相关资源
      最近更新 更多