Home

Awesome

DTTextField

Version License Awesome Platform Xcode

Demo

Introduction

DTTextField is a UITextField library with floating placeholder and error label.

Floating placeholder inspired from JVFloatLabeledTextField :+1:.

Example

Clone the repo and run the example project from the Example directory.

Requirements

Installation

CocoaPods

DTTextField is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'DTTextField'

Swift Package Manager

Click File -> Add Packages..., enter DTTextField repo's URL.

https://github.com/iDhaval/DTTextField

Usage

  1. Open a storyboard or Xib file.
  2. Drag and drop a UITextField to a ViewController.
  3. In Identity Inspector, replace the class from UITextField to DTTextField and the module to DTTextField.

Properties

Property nameTypeRemark
errorMessageStringAdd your error message to this property
errorFontUIFontChange font of error text
errorTextColorUIColorChange color of error text
paddingYErrorLabelCGFloatError text top padding
floatPlaceholderColorUIColorTo change float placeholder color
floatPlaceholderActiveColorUIColorTo change float placeholder color while TextField is active(First responder)
floatPlaceholderFontUIFontChange font of float placeholder
paddingYFloatLabelCGFloatfloat placeholder top padding
placeholderColorUIColorchange placeholder color
animateFloatPlaceholderBoolanimate float placeholder label
hideErrorWhenEditingBoolhide error label when typing
floatingDisplayStatusenummaintain display status always, never, defaults

Important Properties

Property nameTypeRemark
dtLayerCALayerIf you want to formate DTTextField than use dtLayer property instead of layer (e.g. background color)
borderColorUIColorChange border color of DTTextField
canShowBorderBoolToggle border of DTTextField
dtborderStyleenumnone, rounded , sqare , top , bottom , left , right

Methods

Method NameRemark
showErrorto show error message
hideErrorto hide error message

Note

Don't give height constraint to DTTextField otherwise it won't work properly.

TODO

Author

Dhaval Thanki :sunglasses:

License

DTTextField is available under the MIT license. See the LICENSE file for more info.