带边框文本框 (BorderedTextField)

使用 SwiftUI 实现的自定义带边框文本框,边框内显示占位符文本。

用法

此控件可以通过以下不同方式使用

BorderedTextField(placeHolder: .constant("TextField Editable"), text: $text)

BorderedTextField(placeHolder: .constant("TextField Non Editable"), text: $text, isEditingEnabled: false) 

BorderedTextField(placeHolder: .constant("Password Field"), text: $text, isSecureField: true)

BorderedTextField(placeHolder: .constant("Hide PlaceHolder"), text: $text, showBorderPlaceHolder: false, highlightColor: Color.green)

BorderedTextField(placeHolder: .constant("Change Border Color"), text: $text, borderColor: Color.red)

BorderedTextField(placeHolder: .constant("Focus Highlight Color "), text: $text, borderColor: Color.red, highlightColor: Color.green)

Simulator Screen Recording - iPhone 13 Pro - 2022-03-08 at 19 03 06

安装

目前,带边框文本框 (BorderedTextField) 仅通过 Swift Package Manager 提供。 您也可以手动将其添加到您的项目中。

Swift 包管理器 (SPM)

如果您已经设置了 Swift 包,请将带边框文本框 (BorderedTextField) 作为依赖项添加到 Package.swift 文件中的依赖项中。

dependencies: [
    .package(url: "https://github.com/KrishnaRLolage/BorderedTextField.git")
]