Animated UITextField and UITextView replacement for iOS

Overview

AnimatedTextInput GitHub version

iOS custom text input component used in the Jobandtalent app.

Installation

Use cocoapods to install this custom control in your project.

pod 'AnimatedTextInput', '~> 0.3.0'

Usage

Use the main class AnimatedTextInput. Create it either by code or dragging a new instance of UIView into your storyboard/nib file and setting its class in the identity inspector.

Types

Currently there are 6 different types, defined in the AnimatedTextInputType enum.

  • Text: basic text input, same behaviour as UITextField.

  • Password: secure text entry and eye button for revealing its content.

  • Numeric: numeric text input.

  • Selection: user interaction for the text input is disabled. A tapAction is expected and called when the text input is pressed. Normally used to present a set of options and modify its state after one option is selected.

  • Multiline: similar behaviour to UITextView with no scrolling. The intrinsicContentSize of the view will grow as the user types. If you need this behaviour and you use autolayout, pin either the bottom or the top, otherwise the view won't grow (like you would do with a UILabel).

  • Generic: expects a configured TextInput. Use this if you need a UITextField or UITextView with your custom behaviour. Check TextInput and TextInputDelegate protocols and create a class conforming to them.

To switch between types, you can simply use the type property assining one of the values available in the AnimatedTextInputType enum.

textInput.type = .numeric

Styles

Creating a new visual style is as easy as creating a new struct that conforms to the AnimatedTextInputStyle protocol.

For example:

struct CustomTextInputStyle: AnimatedTextInputStyle {

    let activeColor = UIColor.orangeColor()
    let inactiveColor = UIColor.grayColor().colorWithAlphaComponent(0.3)
    let errorColor = UIColor.redColor()
    let textInputFont = UIFont.systemFontOfSize(14)
    let textInputFontColor = UIColor.blackColor()
    let placeholderMinFontSize: CGFloat = 9
    let counterLabelFont: UIFont? = UIFont.systemFontOfSize(9)
    let leftMargin: CGFloat = 25
    let topMargin: CGFloat = 20
    let rightMargin: CGFloat = 0
    let bottomMargin: CGFloat = 10
    let yHintPositionOffset: CGFloat = 7
}

Then, use the style property to set it.

textInput.style = CustomTextInputStyle()

Other considerations

  • You can use AnimatedTextInput as a replacement for either UITextField or UITextView. To set or retrieve the input text, use the text property.

  • This control provides an easy way of setting a counter label. Just call the function showCharacterCounterLabel(with:) and give it a maximum number of characters.

  • AnimatedTextInput has its own delegate methods, very similar to UITextFieldDelegate and UITextViewDelegate.

Download and check the Example project for more examples.


One last question: Why create a TextInput abstraction and not use UITextField or UITextView instead?

From an API point of view, we only wanted to deal with one control. However, we needed some behaviours that were not supported by UITextField or UITextView. For instance, we wanted AnimatedTextInput to support multiline, but UITextField does not support it. We also wanted secure text entry for the password type, but UITextView does not support it. That's why we ended up creating TextInput abstraction.

FAQ

  1. How do I enable autocorrection (or any property available in UITextField or UITextView)? https://github.com/jobandtalent/AnimatedTextInput/issues/67
Comments
  • Input Accessory Toolbar

    Input Accessory Toolbar

    I´ve been trying to implement toolbar for numeric keyboard since it doesn't have a return button, and i need it for my form

    textInputs[0].type = .numeric
    textInputs[0].inputAccessoryView = toolBar
    

    at the moment of doing this is not setting the toolbar and it´s causing an error any ideas?

    opened by cesarmtz93 9
  • Some subviews started to miss.

    Some subviews started to miss.

    First of all, great work guys, new release finally fixed constrains warnings in console. But, this update broke counter label (you can simply look this in example). And another issue i just found with views which i tried to put over the AnimatedTextInput view (actually in AnimatedTextInput view stack via IB with auto layout usage), they are missed and i can't find them :). Just try it.

    bug 
    opened by morfey911 7
  • After backspace, the letter after capital letter makes keyboard uppercase

    After backspace, the letter after capital letter makes keyboard uppercase

    screen shot 2018-01-17 at 14 45 38

    Every time when you delete the previous letters and you stop at the first letter which is an uppercase letter than the keyboard goes all uppercase while it is the 2nd letter ..

    opened by laurenswuyts 5
  • Issue when set text programmatically

    Issue when set text programmatically

    Sometime i want to set text by programmatically but text in animatedtextinput i don't see text. I just only saw placeholder above(To). Can you help me fix this bug. screen shot 2017-08-31 at 9 58 46 am

    opened by hoathuongphuoc 5
  • Fix counter label and add snapshot tests

    Fix counter label and add snapshot tests

    This PR fixes autolayout issues in the counter label.

    It also adds snapshot tests to the project so hopefully this kind of bugs won't happen again in future releases.

    opened by victorBaro 4
  • Phone TextInputType

    Phone TextInputType

    I need to use an AnimatedTextInput that presents a Phone Pad Keyboard Type. Currently there is just the following:

    • Text
    • Password
    • Numeric
    • Selection
    • Multiline
    • Generic

    I need a "Phone" type because .numeric does not allow to have the "+" symbol. The .numeric type has a "." symbol which is not on a phone pad.

    Is there a way I can add this functionality to AnimatedTextInputFieldConfigurator by subclassing it? Im not sure... a bit new to swift.

    I would appreciate some advice / pointers... Thanks

    opened by PeerLabs 3
  • Normal Text input Bug

    Normal Text input Bug

    I have used this library I have find this very useful but I feel there is a minor bug when used the normal text input field and we want to delete some character after selecting the position like we have a text "HelloWorld" in the textfield and I want to delete the "e" from string I have selected the position and deleted "e" but cursor jumps at the end of string always please fix this I will be very thankful .

    opened by hananahmad 3
  • .Multiline Style Not Using Custom Style

    .Multiline Style Not Using Custom Style

    The size of the font is always constant during typing and it's not using the Custom AnimatedTextInputStyle. This happens for .multiline style only...

    http://imgur.com/a/9TD14

    opened by seecahkhing 3
  • Reset Text Input

    Reset Text Input

    How to reset text input after validation is true. If we show validation error then later make it blank. The textField shows red line with no placeholder.

    opened by mukulm24 3
  • Background color for the placeholder still appears

    Background color for the placeholder still appears

    Although everything is nice about this control. the background color in the placeholder does not go away. I understand that author published a version that removes it, but I was not able to get the update with pod

    Thanks a lot in advance

    opened by ttsik 3
  • Added textRange method from UITextInput

    Added textRange method from UITextInput

    Added the standard method open func textRange (from fromPosition: UITextPosition, toPosition: UITextPosition) -> UITextRange? from the UITextInput protocol.

    opened by BarredEwe 0
  • Setting first height bigger

    Setting first height bigger

    I want to set the AnimatedTextInputs first height to 100 (like 3 lines). And the height of the AnimatedTextInput must be grow when the user writing 4 or more rows.

    How can i do this? When i set height its fits like 1 line.

    opened by Hilalkah 0
  • compile errors when using with Swift 3

    compile errors when using with Swift 3

    Hi guys!

    I just downloaded the latest version 0.5.5 with Cocoapods. It seems promising, but I have several build errors with Swift 3. Can you please fix them?

    Nice regards Werner

    opened by pawelnathan 0
Releases(0.5.1)
  • 0.5.0(Apr 17, 2017)

    This new version includes:

    • AttributedString support
    • Swift 3.1 updates
    • Placeholder alignment
    • Clear button mode
    • Show/hide password toggle
    • InputAccessoryView is now a public property
    Source code(tar.gz)
    Source code(zip)
  • 0.4.0(Nov 23, 2016)

    Thank you everyone that submitted a PR adapting it to Swift3. After reviewing them, we decided to go with our own adaptation. This is because it includes a few bug fixings and new features we use in our Jobandtalent app.

    Main changes

    • AnimatedTextInputFieldConfigurator has a new type email
    • Ability to change the return key
    • First responder bug fixed
    • Ability to get/set selected text range
    • Ability to get textPosition
    • Ability to add a disclosure view on the right side of the control (example below) screen shot 2016-11-22 at 20 26 08
    Source code(tar.gz)
    Source code(zip)
  • 0.3.3(Oct 7, 2016)

    • Fix reopened placeholder frame bug: after applying a new style, placeholder frame was too small for the font and letters were cut.
    • Improve becomeFirstResponder behaviour
    • Add new style properties:
      • LineInactiveColor
      • yPlaceholderPositionOffset: allows you to move up/down the placeholder
    Source code(tar.gz)
    Source code(zip)
Owner
jobandtalent
jobandtalent
UITextField and UITextView subclasses with placeholders that change into floating labels when the fields are populated with text.

Deprecated Please use JVFloatLabeledTextField instead or feel free to chime in on an issue if you'd like to take over the repo. RPFloatingPlaceholders

rob phillips 1.1k Jan 5, 2023
Animated Subclass of UITextField created with CABasicAnimation and CAShapeLayer

JDAnimatedTextField JDAnimatedTextField is animateable UITextField that can significantly enhance your user's experiences and set your app apart from

Jawad Ali 25 Dec 13, 2022
Animated UITextField enhance UX for the user by giving clarity that they are focused

JDCircularProgress JDTextField is animateable UITextField that can significantly enhance your user's experiences and set your app apart from the rest

Jawad Ali 22 Nov 17, 2022
An auto-layout base UITextView subclass which automatically grows with user input and can be constrained by maximal and minimal height - all without a single line of code

Deprecated This library is no longer maintained and is deprecated. The repository might be removed at any point in the future. MBAutoGrowingTextView A

Matej Balantič 125 Jan 13, 2022
A light-weight UITextView subclass that automatically grows and shrinks.

RSKGrowingTextView A light-weight UITextView subclass that automatically grows and shrinks based on the size of user input and can be constrained by m

Ruslan Skorb 939 Dec 21, 2022
An UITextView in Swift. Support auto growing, placeholder and length limit.

GrowingTextView Requirements iOS 8.0 or above Installation CocoaPods GrowingTextView is available through CocoaPods. To install it, simply add the fol

Kenneth Tsang 941 Jan 5, 2023
ARAutocompleteTextView is a subclass of UITextView that automatically displays text suggestions in real-time

ARAutocompleteTextView is a subclass of UITextView that automatically displays text suggestions in real-time. This is perfect for automatically suggesting the domain as a user types an email address, #hashtag or @alexruperez.

Alex Rupérez 261 Jun 29, 2022
A light-weight UITextView subclass that adds support for placeholder.

RSKPlaceholderTextView A light-weight UITextView subclass that adds support for placeholder. Installation Using Swift Package Manager To add the RSKPl

Ruslan Skorb 220 Dec 17, 2022
A UITextView subclass that adds support for multiline placeholder written in Swift.

KMPlaceholderTextView A UITextView subclass that adds support for multiline placeholder written in Swift. Usage You can set the value of the placehold

Zhouqi Mo 795 Nov 18, 2022
DGPlaceholderTextView - A light-weight UITextView that supports for placeholder

DGPlaceholderTextView Requirements Installation Usage Properties DGPlaceholderTe

donggyu 5 Jan 26, 2022
iOS - Subclass of UITextField to achieve autocompletion for Place Search like Google Places, Uber and Much more apps having maps.

MVAutocompletePlaceSearchTextField iOS - Subclass of UITextField to achieve autocompletion for Place Search like Google Places, Uber and Much more app

Mrugrajsinh Vansadia 68 May 27, 2022
🏄‍♂️ UITextField-Navigation makes it easier to navigate between UITextFields and UITextViews

' __________________ _______ _________ _______ _________ _______ _ ______ ' |\ /|\__ __/\__ __/( ____ \|\ /

Thanh Pham 446 Nov 24, 2022
UITextField with underline and left image

TJTextField UITextField with underline and left image Version: 1.0 Features Add image in UITextField Left text pedding Underline whole UITextField Sho

Tejas Ardeshna 44 May 16, 2022
UITextfield subclass with autocomplete menu. For iOS.

MLPAutoCompleteTextField "We believe that every tap a user makes drains a tiny bit of their energy and patience. Typing is one of the biggest expendit

Eddy Borja 1.2k Nov 11, 2022
An UITextField subclass to simplify country code's picking. Swift 5.0

Preview Installation NKVPhonePicker is available through CocoaPods. To install it, simply add the following line to your Podfile: pod 'NKVPhonePicker'

Nike Kov 140 Nov 23, 2022
HTYTextField A UITextField with bouncy placeholder.

HTYTextField - A UITextField with bouncy placeholder. Screenshot Installation CocoaPods Add the dependency to your Podfile

Hanton Yang 312 Nov 13, 2022
Fully-wrapped UITextField made to work entirely in SwiftUI

iTextField ⌨️ A fully-wrapped `UITextField` that works entirely in SwiftUI. ?? Get Started | Examples | Customize | Install | Get Started Install iTex

Benjamin Sage 89 Jan 2, 2023
UITextField character counter with lovable UX 💖. No math skills required 🙃.

TextFieldCounter UITextField character counter with lovable UX ??. No math skills required ??. Features Set max length of UITextField. A beautiful an

Fabricio Serralvo 434 Dec 22, 2022
UITextField subclass with floating labels

JVFloatLabeledTextField JVFloatLabeledTextField is the first implementation of a UX pattern that has come to be known the "Float Label Pattern". Due t

Jared Verdi 7.2k Jan 2, 2023