GBFloatingTextField 2.0.0

GBFloatingTextField 2.0.0

Gurinder Singh Batth 维护。



  • 作者
  • Gurinder Batth

GBFloatingTextField

CI Status Version License Platform

示例

要运行示例项目,请克隆仓库,然后首先从 Example 目录中运行 pod install

要求

  • iOS 9.0+
  • Xcode 9.3+
  • Swift 4+

安装

GBFloatingTextField 通过 CocoaPods 提供。要安装它,只需将以下行添加到您的 Podfile 中

pod 'GBFloatingTextField'

GBFloatingTextField 新功能

为 TextView 添加相同的功能。有关更多信息,请参阅 GBFloatingTextView 的用法。

GBFloatingTextField 用法

要创建类的实例,请使用 Interface builder 或从代码中进行。此示例将创建以下带有占位符、标题、行和错误信息的 textField

let textField = GBTextField(frame: CGRect(x:10, y: 100, width: UIScreen.main.bounds.width - 20, height: 40))
textField.lineColor = .black
textField.titleLabelColor = .black
textField.lineHeight = 1
textField.showErrorMessage("This is Text Error")
self.view.addSubview(textField)

以下是一些可以更改的属性列表。请检查这些自定义项。

GBFloatingTextView 用法

要创建类的实例,请使用 Interface builder 或从代码中进行。此示例将创建以下带有占位符和标题的 textView

您无需将此视图添加到Superview中,只需在创建 GBFloatingTextView 实例时传入Superview即可。例如。

let textView = GBFloatingTextView(frame: CGRect(x: 10, y: 200, width: 355, height: 150), superView: self.view)
textView.isFloatingLabel = true
textView.placeholder = "GBFloating TextView"

要更改占位符颜色、顶部占位符颜色或选中占位符颜色。请检查这些属性。

textView.placeholderColor = .gray
textView.topPlaceholderColor = .black
textView.selectedColor = .red

要启用 GBFloatingTextView 中的浮动文本。请启用 "isFloatingLabel",请注意这将隐藏浮动文本,如 UITextField 中的占位符文本。

isFloatingLabel 默认为 false。请将其设置为 true 以启用浮动占位符。

您可以在 Interface builder 中更改 GBFloatingTextField 和 GBFloatingTextView 的所有属性。

贡献

我们欢迎所有贡献。

作者

Gurinder Batth, [email protected]

鸣谢

对于Secure Entry错误的功劳,以及在其帮助下通过SkyFloatingLabelTextField进行改进。

特别感谢

特别感谢Mixel为TextView添加动画效果。

许可证

GBFloatingTextField在MIT许可证下可用。有关更多信息,请参阅LICENSE文件。

已知问题

如果clipsToBounds或masksToBounds属性设置为true,则不会工作。

关于未来版本

  1. 正在努力使其适用于TextView。
  2. 解决已知问题
  3. 我们将尝试让每个人都能使用并根据他们的需求定制。
  4. 将添加RTL语言支持。