πŸ„β€β™‚οΈ UITextField-Navigation makes it easier to navigate between UITextFields and UITextViews

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

UITextField-Navigation

CI Status GitHub issues Codecov Documentation

GitHub release Platform License

Carthage

CocoaPods

Say thanks!

Description

UITextField-Navigation adds next, previous and done buttons to the keyboard for your UITextFields and UITextViews. It allows you to specify a next field either on the Interface Builder or programmatically. Then, you can access next and previous fields of each UITextField or UITextView easily.

The UI is highly customizable. RTL languages are supported.

To run the example project:

pod try UITextField-Navigation

Screenshot 0 Screenshot 1 Screenshot 2

Usage

Basic

You can set the nextNavigationField property for each UITextField and UITextView either on the Interface Builder or programmatically. The previousNavigationField property will be set on the other UITextField or UITextView automatically for you.

Example:

import UITextField_Navigation

...
let textField = UITextField()
let textView = UITextView()
textField.nextNavigationField = textView

assert(textView == textField.nextNavigationField)
assert(textField == textView.previousNavigationField)

Please note that the nextNavigationField and previousNavigationField properties are not retained.

Capturing taps

To capture taps on the next, previous and done buttons, assign a delegate to your NavigationField, which is a UITextField or UITextView, also either on the Interface Builder or programmatically. Then implement the NavigationFieldDelegate protocol (in addition to the UITextFieldDelegate or UITextViewDelegate protocol) for the delegate. Please note that you have to explicitly declare that the delegate conforms to the NavigationFieldDelegate protocol to make it work.

Swift:
import UIKit
import UITextField_Navigation

...
extension ViewController: NavigationFieldDelegate { // explicitly protocol conforming declaration

    func navigationFieldDidTapPreviousButton(_ navigationField: NavigationField) {
        navigationField.previousNavigationField?.becomeFirstResponder()
        // your custom work
    }

    func navigationFieldDidTapNextButton(_ navigationField: NavigationField) {
        navigationField.nextNavigationField?.becomeFirstResponder()
        // your custom work
    }

    func navigationFieldDidTapDoneButton(_ navigationField: NavigationField) {
        navigationField.resignFirstResponder()
        // your custom work
    }
}
Objective-C:
@import UITextField_Navigation;
#import "ViewController.h"

@interface ViewController () <NavigationFieldDelegate> // explicitly protocol conforming declaration

...
#pragma mark - NavigationFieldDelegate

- (void)navigationFieldDidTapPreviousButton:(id<NavigationField>)navigationField {
    [navigationField.previousNavigationField becomeFirstResponder];
    // your custom work
}

- (void)navigationFieldDidTapNextButton:(id<NavigationField>)navigationField {
    [navigationField.nextNavigationField becomeFirstResponder];
    // your custom work
}

- (void)navigationFieldDidTapDoneButton:(id<NavigationField>)navigationField {
    [navigationField resignFirstResponder];
    // your custom work
}

Set button titles

The titles of the previous, next and done buttons can be modified for each instant by setting the title property of each corresponding button.

navigationField.navigationFieldToolbar?.previousButton.title = "Previous"
navigationField.navigationFieldToolbar?.nextButton.title = "Next"
navigationField.navigationFieldToolbar?.doneButton.title = "Dismiss"

Or they can be set globally for all instances using Config.

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
    UITextField_Navigation.Config.previousButtonTitle = "Previous"
    UITextField_Navigation.Config.nextButtonTitle = "Next"
    UITextField_Navigation.Config.doneButtonTitle = "Done"
    return true
}

UI Customization

Using UIAppearance

Modify the appearance proxy of the NavigationFieldToolbar and NavigationFieldToolbarButtonItem classes to customize the navigation view's UI for all fields.

NavigationFieldToolbar.appearance().barStyle = .black
NavigationFieldToolbar.appearance().backgroundColor = .purple
if #available(iOS 11.0, *) {
    UIButton.appearance(whenContainedInInstancesOf: [NavigationFieldToolbar.self]).tintColor = .white
} else {
    NavigationFieldToolbarButtonItem.appearance().tintColor = .white
}

Screenshot 3

Directly and adding more buttons

Alternatively, you can directly modify the UI of each navigation view by accessing the navigationFieldToolbar property of a UITextField or UITextView.

...
navigationField.navigationFieldToolbar?.barStyle = .default
navigationField.navigationFieldToolbar?.backgroundColor = .red

// Add a custom button
let customButton = UIBarButtonItem(title: "Custom", style: .plain, target: nil, action: nil)
let flexibleSpace = UIBarButtonItem(barButtonSystemItem: .flexibleSpace, target: nil, action: nil)
navigationField.navigationFieldToolbar?.items = [navigationField.navigationFieldToolbar!.previousButton, navigationField.navigationFieldToolbar!.nextButton, customButton, flexibleSpace, navigationField.navigationFieldToolbar!.doneButton]

Screenshot 4

Installation

Carthage

Add the line below to your Cartfile:

github "T-Pham/UITextField-Navigation"

CocoaPods

Add the line below to your Podfile:

pod 'UITextField-Navigation'

Manually

  1. Download and drop /UITextField-Navigation/Classes folder in your project.
  2. Congratulations!

Compatibility

  • Swift 4, 5: please use the latest version
  • Swift 3: please use version 3.0.0
  • Swift 2: please use version 1.4.3

Apps that use UITextField-Navigation

Hello fellow developers. I can see that the library has been adopted in some apps. If your app also uses the library, it would be great if you can share it here. Please add it to the list below. Thanks!

  1. Catder - Random animated cat photos
  2. Gradus - a Grade Calculator

License

UITextField-Navigation is available under the MIT license. See the LICENSE file for more info.

Comments
  • Storyboard Connection Inspector - Sent Actions panel is missing

    Storyboard Connection Inspector - Sent Actions panel is missing

    Hello!

    I'm trying to connect one UITextField to another via Storyboard Connection Inspector and it just not allowing me to do so.

    Either in the code:

    let firstField = UITextField()
    let anotherField = UITextField()
    
    firstField.nextNavigationField = anotherField
    firstField.nextNavigationField == nil // true
    

    But I still can connect UITextField.nextNavigationField to UITextView. And can't do vice versa.

    Have you noticed this, or it happens only to me?

    opened by VitaliyR 10
  • UITextField.nextNavigationField = UITextView not working

    UITextField.nextNavigationField = UITextView not working

    First thing, thanks for this library, the exact little addon that makes the life easier. Unfortunately when I'm trying to do something like UITextField.nextNavigationField = UITextView, I don't get next arrow (it's disabled) so I can't go to the UITextView via the library's toolbar if I'm in UITextField. Note that UITextField.nextNavigationField = UITextField working great so the problem is only when setting UITextField.nextNavigationField = UITextView.

    Thanks, Ido.

    opened by Idomo 7
  • log to console

    log to console

    Whenever two text fields are connected via nextNavigationField following types of log messages occur

    Reading from private effective user settings. navigationFieldDidTapNextButton: <UITextField: 0x7fb48d725cb0; frame = (0 0; 328 30); text = '100'; clipsToBounds = YES; opaque = NO; autoresize = RM+BM; gestureRecognizers = <NSArray: 0x60800045aa90>; layer = <CALayer: 0x600000035a20>> navigationFieldDidTapNextButton: <UITextField: 0x7fb48d61c780; frame = (0 0; 328 30); text = ''; clipsToBounds = YES; opaque = NO; autoresize = RM+BM; gestureRecognizers = <NSArray: 0x60000025e1e0>; layer = <CALayer: 0x600000036d40>> navigationFieldDidTapNextButton: <UITextField: 0x7fb48d6201e0; frame = (0 0; 328 30); text = ''; clipsToBounds = YES; opaque = NO; autoresize = RM+BM; gestureRecognizers = <NSArray: 0x600000440ed0>; layer = <CALayer: 0x600000037b80>> navigationFieldDidTapNextButton: <UITextField: 0x7fb48d625590; frame = (0 0; 328 30); text = ''; clipsToBounds = YES; opaque = NO; autoresize = RM+BM; gestureRecognizers = <NSArray: 0x60000044a5c0>; layer = <CALayer: 0x6000000394c0>> navigationFieldDidTapNextButton: <UITextField: 0x7fb48d628c40; frame = (0 0; 328 30); text = ''; clipsToBounds = YES; opaque = NO; autoresize = RM+BM; gestureRecognizers = <NSArray: 0x60000044d2f0>; layer = <CALayer: 0x60000003a320>> navigationFieldDidTapNextButton: <UITextField: 0x7fb48d628c40; frame = (0 0; 328 30); text = ''; clipsToBounds = YES; opaque = NO; autoresize = RM+BM; gestureRecognizers = <NSArray: 0x60000044d2f0>; layer = <CALayer: 0x60000003a320>> Though no problem with running of app is found but why this log message appears should be investigated. Thanks

    opened by nikhilpandey4 6
  • Proper usage when form contains textfields and textviews

    Proper usage when form contains textfields and textviews

    Hi!

    Thanks for the awesome pod, works flawlessly.

    The only question I have is how to use it within a form which contains textview - how to map in proper way nextTextField?

    Thanks!

    opened by VitaliyR 4
  • Next navigation field not showing in Storyboard if TextfieldNavigation is installed via carthage

    Next navigation field not showing in Storyboard if TextfieldNavigation is installed via carthage

    Hi Next navigation field is unavailable in storyboard and is available only in code if UITextfield_Navigation is installed via Carthage but available in storyboard and user can connect visually two text fields if UITextfield_Navigation is installed via cocoa pods.

    opened by nikhilpandey4 3
  • When using Password Keychain, the UITextField-Navigation is still appears at the bottom (iPhone X)

    When using Password Keychain, the UITextField-Navigation is still appears at the bottom (iPhone X)

    Hi, When I have 2 UITextFields (email & password) and I'm focusing one of them, I have an option to choose password from the iCloud Password Keychain and then the keyboard is going down, but the UITextField-Navigation is still appear at the bottom.

    *Note that I have also 1Password activated as an source of passwords (so I have ActionSheet to choose between it and the build-in Keychain, and there you can see the problem). Also note that I'm using iPhone X on iOS 12 (I don't know if it's only happens with the X or also with other screens).

    Of course this is only a tiny UI issue so this is in low priority, but just posting it here if you'll find some time in the further and you'll want to fix it ;)

    Thanks, Ido.

    opened by Idomo 2
  • Globally customize NavigationFieldToolbar

    Globally customize NavigationFieldToolbar

    First of all thank you very much for creating this library. I have used it in multiple projects and it has saved me a ton of customization code!

    My issue is that is there currently an easy way of globally modifying the previousButton, nextButton, and doneButton titles without subclassing? The current workaround I did is that I unlocked and modified the NavigationFieldToolbar.swift file and manually replaced the string literals there.

    opened by garrialmighty 2
  • iOS 11 - tint color isn't applied to NavigationBar

    iOS 11 - tint color isn't applied to NavigationBar

    Hello.

    On iOS 11 tint color not applied to NavigationBar.

    NavigationFieldToolbarButtonItem.appearance().tintColor = UIColor.white
    

    Is works for iOS 10 but isn't for iOS 11

    opened by VitaliyR 2
  • Getting error while using the library in Xcode 9

    Getting error while using the library in Xcode 9

    Hi, While using the library in Xcode Version 9.0 beta 6 (9M214v), I am getting the error that modules Module compiled with Swift 3.1 cannot be imported in Swift 3.2/ Swift 4.0. Now new iPhone launch is just one week ahead on 12th September and even the Xcode 9 GM seed will be launched on the same day. Requested to update the project to at least Swift 3.2.

    opened by nikhilpandey4 2
  • Extending this to UITextView?

    Extending this to UITextView?

    I was going to extend this to work for a UITextView...is there any desire to create a separate Pod for that or should I keep it consolidated to my project?

    opened by chriscohoat 2
  • Warning appears when we upload Xcode to 9.3 with Swift 4.1

    Warning appears when we upload Xcode to 9.3 with Swift 4.1

    Hi while upgrading to Xcode 9.3 with Swift 4.1 following warning appears

    'weak' should not be applied to a property declaration in a protocol and will be disallowed in future versions

    And then Xcode 9.3 takes to following lines of code

    `protocol NavigationFieldInternal: NavigationField, NavigationFieldToolbarDelegate {

    var internal_delegate: AnyObject? { get }
    **weak var internal_nextNavigationField: NavigationField? { get set }
    weak var internal_previousNavigationField: NavigationField? { get set }**
    
    func internal_applyInputAccessoryView()
    
    func storeNavigationField(_ navigationField: NavigationField?, key: UnsafeRawPointer)
    func retrieveNavigationField(key: UnsafeRawPointer) -> NavigationField?
    

    }`

    opened by nikhilpandey4 1
  • LayoutConstraints warning since iOS 13

    LayoutConstraints warning since iOS 13

    Hi, Since I've upgraded to xCode 11 (GM) with the iOS 13 SDK, I got a warning about constraints each time the UIToolBar of the library was displayed. I didn't change anything on the constraints side so I'm guessing this is an issue with the library itself. I'd appreciate if you'll take a look on this and may find a fix.

    Thanks, Ido.

     [LayoutConstraints] Unable to simultaneously satisfy constraints.
    	Probably at least one of the constraints in the following list is one you don't want. 
    	Try this: 
    		(1) look at each constraint and try to figure out which you don't expect; 
    		(2) find the code that added the unwanted constraint or constraints and fix it. 
    	(Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints) 
    (
        "<NSAutoresizingMaskLayoutConstraint:0x600000dc66c0 h=--& v=--& _UIToolbarContentView:0x7fb42fef2770.height == 0   (active)>",
        "<NSLayoutConstraint:0x600000df75c0 V:|-(0)-[_UIButtonBarStackView:0x7fb42fef3240]   (active, names: '|':_UIToolbarContentView:0x7fb42fef2770 )>",
        "<NSLayoutConstraint:0x600000df7610 _UIButtonBarStackView:0x7fb42fef3240.bottom == _UIToolbarContentView:0x7fb42fef2770.bottom   (active)>",
        "<NSLayoutConstraint:0x600000dd1fe0 UIButtonLabel:0x7fb42ffbbc90'\U05e1\U05d9\U05d5\U05dd'.centerY == _UIModernBarButton:0x7fb42fddc4a0'\U05e1\U05d9\U05d5\U05dd'.centerY + 0.5   (active)>",
        "<NSLayoutConstraint:0x600000dc5270 'TB_Baseline_Baseline' _UIModernBarButton:0x7fb42fddc4a0'\U05e1\U05d9\U05d5\U05dd'.lastBaseline == UILayoutGuide:0x600001786680'UIViewLayoutMarginsGuide'.bottom   (active)>",
        "<NSLayoutConstraint:0x600000dc52c0 'TB_Top_Top' V:|-(>=0)-[_UIModernBarButton:0x7fb42fddc4a0'\U05e1\U05d9\U05d5\U05dd']   (active, names: '|':_UIButtonBarButton:0x7fb42fddc2d0 )>",
        "<NSLayoutConstraint:0x600000dc54a0 'UIButtonBar.maximumAlignmentSize' _UIButtonBarButton:0x7fb42fddc2d0.height == UILayoutGuide:0x600001782300'UIViewLayoutMarginsGuide'.height   (active)>",
        "<NSLayoutConstraint:0x600000df73e0 'UIView-bottomMargin-guide-constraint' V:[UILayoutGuide:0x600001782300'UIViewLayoutMarginsGuide']-(0)-|   (active, names: '|':_UIButtonBarStackView:0x7fb42fef3240 )>",
        "<NSLayoutConstraint:0x600000dc51d0 'UIView-bottomMargin-guide-constraint' V:[UILayoutGuide:0x600001786680'UIViewLayoutMarginsGuide']-(16)-|   (active, names: '|':_UIButtonBarButton:0x7fb42fddc2d0 )>",
        "<NSLayoutConstraint:0x600000df7340 'UIView-topMargin-guide-constraint' V:|-(0)-[UILayoutGuide:0x600001782300'UIViewLayoutMarginsGuide']   (active, names: '|':_UIButtonBarStackView:0x7fb42fef3240 )>"
    )
    
    Will attempt to recover by breaking constraint 
    <NSLayoutConstraint:0x600000dd1fe0 UIButtonLabel:0x7fb42ffbbc90'Done.centerY == _UIModernBarButton:0x7fb42fddc4a0'Done.centerY + 0.5   (active)>
    
    Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
    The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKitCore/UIView.h> may also be helpful.
    
    opened by Idomo 2
  • RTL (Right to left) problem and suggestion to solve it + asking for new option

    RTL (Right to left) problem and suggestion to solve it + asking for new option

    When using the library with device that it's main language is RTL (right to left) the right/left arrows are replacing positions and it's a little bit confusing. Beside fix the arrows to not be language directional, I'd like to suggest add an configuration option to use up/down arrows thats won't make this problem with RTL languages to be so visible and also allow choose different appearance. It will be awesome if this configuration will be in the AppDelegate.swift so it will change it all over the application.

    In additional to the last sentence I'd like to ask adding an option to change the buttons as UIBarButtonItem and not just as text, so we will be able to change it to buttons like Done, Save etc. that already found as default in the iOS and also translating automatically and make the button bold in some cases, right now the only way to do that is to config it manually to each UITextField, it will be much better to have an option to change that at the AppDelegate.swift.

    Thanks, Ido.

    opened by Idomo 12
Owner
Thanh Pham
πŸ‘¨β€πŸ’» iOS & Roku
Thanh Pham
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
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 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
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
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
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
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
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 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
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