Skip to content

zDILIGENCEz/RTFInput

Repository files navigation

RTFInput

This is a cocoapods librarry which implement custom UITextFileds based on RxSwift and RxCocoa.

CI Status Version License Platform

Demo

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Installation

Cocoapods

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

pod 'RTFInput'

Then, run the following command:

$ pod install

Quick Start

1. Import RTFInput

Import RTFInput module where you want to use it:

import RTFInput

2. Initialization

Create RTFInput by code, using initializer.

lazy var textInputView = RTFInput()

2. Customize

You can easily edit any of the elements as you want! All you need is to change setting. RTFInputSetting is required for RTFInput to work properly, which concise all the settings and customizations together into one single builder function. Here are the steps:

  1. Initialize RTFInputSetting instance by using RTFInputSetting.Builder
  2. Add features & customizations
  3. Setup RTFInput by created RTFInputSetting instance
lazy var firstTextInputView: RTFInput = {
    let textInputView = RTFInput()
    let setting = RTFInputSettings.Builder.instance()
        // Add Your customize code here
        .build()
    textInputView.setup(setting: setting)
    return textInputView
}()

- change theme

You can easily change the theme, just specify one of the values:

  • standard (Default)
.theme(.standard)
  • dark
.theme(.dark)
  • light
.theme(.light)

Please note that if theme and color customization, e.g. textColor, are both setup in builder, the text color from theme will be ignored.

- change colors

You can change all elements You want. Background, text, placeholder and other.

just add next code:

to change plaseholder color

.placeholderColor(.red)

to change text color

.textColor(.blue)

to change background color

.backgroundColor(.yellow)

to change cursor color

.cursorColor(.purple)

to change floating hint text color

.accentColor(.brown)

to change warning text color

.warningColor(.green)

- change secure value

Also you can change the secure value to your text

.secure(true)

- configure warnings

You can configure the error message and action if You need it.

  • number
  • phone
  • password
  • email
  • index
  • cardNumber
  • cardValidity
  • CVV

or You can write your custom regular expression

  • regex(pattern: String)
.inputType(
    .email,
    onViolated: (
        message: "Invalid email",
        callback: nil
    )
)

Author

Nikita Kusyumov, n.kusyumov@mail.ru

License

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

About

Add reactive TextFields into your project.

Resources

License

Stars

Watchers

Forks

Packages

No packages published