A custom UITextField with animations on 'didBeginEditing' and 'didEndEditing' events. It provides some icons for textfield's clearButton and support for your custom icon. This is written in Swift.
- BorderBottom animation
- Custom borderBottom color for default state and active state in IB or programmatically
- Custom clearButton alpha, color and icon
- Swift Package Manager:
dependencies: [
.package(url: "https://github.com/fernandacarvalho/FCTextField/tree/master/Package", .upToNextMajor(from: "1.0.0"))
]
- Manually:
If you prefer not to use any dependency manager, you can find the binary framework on build folder and integrate FCTextField into your project manually.
Then, import FCTextField:
import FCTextField
- Open a storyboard or Xib file.
- Drag and drop a UITextField to a ViewController.
- In Identity Inspector, replace the class from UITextField to FCTextField.
- Configure properties in the Attribute Inspector
If you want to show clearButton:
-
Change 'Clear Button' property from 'Never appears' to 'Appears while editing'
-
Create an IBOutlet in your class and set 'clearButtonType' property. You can choose between:
- iosDefault (native icon)
- simple
- rounded
- outlineRounded
- arrow
- outlineArrow
- roundCorner
- squareCorner
- custom (user provides the image)
Ex: myTextField.clearButtonType = .outlineRounded
-
Choose the color and the alpha of the clearButton
If you choose ClearButtonType.custom:
- Set your image. Ex: myTextField.customClearButtonImage = yourImage
- If the type isn't chosen, the .iosDefault will be applied and the ios native icon for clear button will appear.
- If the type chosen is .custom but the image isn't provided, the ios native icon for clear button will appear.
- You can see the usage in the ExampleApp