This is a cocoapods librarry which implement custom UITextFileds based on RxSwift and RxCocoa.
To run the example project, clone the repo, and run pod install
from the Example directory first.
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
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:
- Initialize
RTFInputSetting
instance by usingRTFInputSetting.Builder
- Add features & customizations
- Setup
RTFInput
by createdRTFInputSetting
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
- index
- cardNumber
- cardValidity
- CVV
or You can write your custom regular expression
- regex(pattern: String)
.inputType(
.email,
onViolated: (
message: "Invalid email",
callback: nil
)
)
Nikita Kusyumov, n.kusyumov@mail.ru
RTFInput is available under the MIT license. See the LICENSE file for more info.