UITextField character counter with lovable UX πŸ’–. No math skills required πŸ™ƒ.

Overview

TextFieldCounter

UITextField character counter with lovable UX πŸ’–. No math skills required πŸ™ƒ.

Swift Version License Build Status codecov CocoaPods

Features

  • Set max length of UITextField.
  • A beautiful and animated label about the limits. Show it by ascending or descending way.
  • Haptic Feedback.
  • Easy setup with @IBInspectable.

TextFieldCounter

Requirements

TextFieldCounter Version 1.1.0 1.0.4
iOS Version 10.0+ 8.0+
Xcode Version 11.2 8

Installation

CocoaPods

You can use CocoaPods to install TextFieldCounter by adding it to your Podfile:

platform :ios, '10.0'
use_frameworks!
pod 'TextFieldCounter'

To get the full benefits import TextFieldCounter wherever you import UIKit

import UIKit
import TextFieldCounter

Manually

  1. Download and drop TextFieldCounter.swift in your project.
  2. Congratulations πŸš€

Usage example

By Inspector

  1. Set the class and configure the options.

Inspector

Programmatically

import TextFieldCounter

let frame = CGRect(x: 20, y: 80, width: 320, height: 30)
let textField = TextFieldCounter(frame: frame, limit: 20, animate: true, ascending: true, counterColor: .black, limitColor: .red)

view.addSubview(textField)
Use Delegate

Set counterDelegate and enjoy it πŸš€ :

override func viewDidLoad() {
    super.viewDidLoad()
    textField.counterDelegate = self
}

func didReachMaxLength(textField: TextFieldCounter) {
    print("didReachMaxLength")
}

Next Steps

  • Add UIAppearance support
  • Add More tests
  • Add Carthage support

Contribute

We would ❀️ to see your contribution! To contribute to TextFieldCounter, check the LICENSE file for more info.

License

Distributed under the MIT license. See LICENSE for more information.

About

Created by Fabricio Serralvo – serralvo.co

Special thanks πŸ‘ to @ciceroduarte and @rogerluan

Comments
  • Setting UITextFieldDelegate in ViewController for the custom TextField

    Setting UITextFieldDelegate in ViewController for the custom TextField

    If I set the UITextFieldDelegate in my own ViewController, the TextFieldCounter class doesn't get any delegate callbacks from UITextFieldDelegate and so it doesn't work anymore.

    Is it possible to support both delegates?

    enhancement 
    opened by patricks 4
  • Fix incorrect counter on changing more than one character at once

    Fix incorrect counter on changing more than one character at once

    On selection and then deleting / pasting / cutting text wrong text length was displayed. The reason is not checking shouldChangeCharactersIn parameter.

    I also had to set correct range in tests. Parameter shouldChangeCharactersIn should be (0, 0), because it is initial text input.

    opened by filletofish 4
  • Pod version outdated

    Pod version outdated

    It seems the version in the cocoapods repo is outdated, as the class is not open. This causes that when importing the module, the class can't actually be used. Would be great to fix it!! In the meantime I'll work against the repo master branch.

    opened by andres-cianio 4
  • Use of undeclared type 'TextFieldCounter'

    Use of undeclared type 'TextFieldCounter'

    Hey,

    Thanks for your awesome repo. I installed the latest version Installing TextFieldCounter (0.0.2) and I imported it import TextFieldCounter however, I got this error:

    screen shot 2017-05-11 at 10 33 51 am

    What is the problem?!

    Thanks.

    bug 
    opened by Maryom 3
  • Localizing counterLabel

    Localizing counterLabel

    This includes:

    • Localizing the number on counterLabel.
    • Changing the counterLabel text alignment to work well on both left to right and right to left layouts.

    Before on right to left layouts: screen shot 2017-08-27 at 7 31 37 am Notice how the number is very close to the edge of the text field, that because of the text alignment.

    After: screen shot 2017-08-27 at 7 42 40 am

    opened by i3li 2
  • Updates tests to give more readability

    Updates tests to give more readability

    Now our tests is not using a good naming spec, IMO we should update that.

    https://github.com/serralvo/TextFieldCounter/blob/master/TextFieldCounter/TextFieldCounterTests/TextFieldCounterTests.swift

    Good referente to follow: https://qualitycoding.org/unit-test-names/

    hacktoberfest 
    opened by serralvo 1
  • Fixed crash, added descending feature, AutoLayout and UI additions

    Fixed crash, added descending feature, AutoLayout and UI additions

    • Fixed issue where missing Storyboard outlet caused demo app to crash
    • @IBInspectable and programmatic init now has option to set ascending or descending counter (default still ascending)
    • Added AutoLayout to demo app. Previously the UI would not display correctly if the screen width did not equal 750.
    • Updated label naming convention on programmatic init to be shorter / cleaner
    • Programmatic init now stylizes TextFieldCounter background color and border to appear like a vanilla UITextField. Previously, programmatic init could appear invisible to the user.
    opened by jerherrero 1
  • Block-Style Interaction?

    Block-Style Interaction?

    Hey,

    It's a matter of taste, but if I were going to use TextFieldCounter (I'm not, currently), I'd prefer a block for handling when max length is reached.

    textField.onMaxLengthCrossed { overLimit in
      submitButton.isEnabled = !overLimit
    }
    

    I don't love onMaxLengthCrossed as a name, but I couldn't think of anything better right away, so if you decide to add a block handler, maybe you can think of a better name.

    On that note, it seems important to have a notification on the delegate if the max limit is "unreached" as well -- for instance in the block above, to re-enable the submit button.

    enhancement 
    opened by geoffreywiseman 1
Releases(1.1.0)
Owner
Fabricio Serralvo
πŸ‘¨β€πŸ’» iOS Software Engineer at iFood πŸŽ™ Co-host at Build Failed Podcast
Fabricio Serralvo
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-Navigation makes it easier to navigate between UITextFields and UITextViews

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

Thanh Pham 446 Nov 24, 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
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
This project will add a done button on your UITextField and UITextView

This project will add a done button on your UITextField and UITextView

Botla Venkatesh 0 Nov 23, 2021
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
UITextField category that adds shake animation

UITextField category that adds a shake animation like the password field of the OsX login screen. Screenshot Setup with CocoaPods pod 'UITextField+Sha

Andrea Mazzini 749 Dec 13, 2022
UITextField extension in Swift that adds shake animation

UITextField-Shake-Swift UITextField extension in Swift that adds shake animation Initially created by Andrea Mazzini (using Objective-C) on 08/02/14:

null 15 Jul 20, 2021
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
Subclass of UITextField that shows inline suggestions while typing.

AutocompleteField Subclass of UITextField that shows inline suggestions while typing. Plug and play replacement for UITextField. Delimiter support. Pe

Filip Stefansson 663 Dec 6, 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
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 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
UITextField that automatically formats text to display in the currency format

CurrencyTextField The numbers that the user enters in the field are automatically formatted to display in the dollar amount format. For example, if th

Richa Deshmukh 49 Sep 28, 2022
UITextField that support currency in the right way.

PLCurrencyTextField Summary PLCurrencyTextField provides simple and user friendly support for the amount in the currency. Usage To start using the com

Łukasz ŚliwiΕ„ski 96 Nov 14, 2022
Animated UITextField and UITextView replacement for iOS

AnimatedTextInput iOS custom text input component used in the Jobandtalent app. Installation Use cocoapods to install this custom control in your proj

jobandtalent 757 Dec 15, 2022
UITextField subclass with autocompletion suggestions list

SearchTextField Overview SearchTextField is a subclass of UITextField, written in Swift that makes really easy the ability to show an autocomplete sug

Alejandro Pasccon 1.1k Dec 28, 2022
UITextField-based control for (NS)Measurement values input.

MeasurementTextField UITextField-based control for (NS)Measurement values input. Provides type-safe keyboard and picker based input of different measu

Siarhei Fiedartsou 16 Jul 22, 2021