📝 The next in the generations of 'growing textviews' optimized for iOS 8 and above.

Overview

NextGrowingTextView

Version Carthage compatible License Platform FOSSA Status

The next in the generations of 'growing textviews' optimized for iOS 8 and above.

example1

As a successor to HPGrowingTextView, NextGrowingTextView was redesigned from scratch to provide the most elegant architecture for iOS 8 and above.

Most autoresizing textviews are implemented with UITextView subclasses. The problem with that approach is that each iOS version changed UITextView's layout behavior, and so most of the implementations are laden with iOS version-specific workarounds to fix bugs and errant behavior. With NextGrowingTextView, the battle with the framework is now over.

NextGrowingTextView approaches the problem differently by wrapping UITextView within a UIScrollView and aligning the textView to the scrollView's contentSize.

- public NextGrowingTextView: UIScrollView
    - internal NextGrowingInternalTextView: UITextView

💡
You want also to need to display a user-interface on top of the keyboard?
muukii/Bureau enables you to show your user-interface on top of the keyboard in the easiest way.

Usage

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

Properties

public class Delegates {
  public var willChangeHeight: (CGFloat) -> Void
  public var didChangeHeight: (CGFloat) -> Void
}

public var delegates: Delegates
public override init(frame: CGRect)

Use isFlashScrollIndicatorsEnabled to enable/disable flash scroll indicators while text view height is less than max height.

Delegates

let growingTextView: NextGrowingTextView

growingTextView.delegates.didChangeHeight = { [weak self] height in
  guard let `self` = self else { return }
  // Do something
}

Requirements

iOS 9.0+ Swift 4.2+

Installation

CocoaPods

CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:

$ gem install cocoapods

CocoaPods 0.39.0+ is required to build NextGrowingTextView

To integrate NextGrowingTextView into your Xcode project using CocoaPods, specify it in your Podfile:

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
use_frameworks!

pod 'NextGrowingTextView'

Then, run the following command:

$ pod install

Carthage

Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.

You can install Carthage with Homebrew using the following command:

$ brew update
$ brew install carthage

To integrate NextGrowingTextView into your Xcode project using Carthage, specify it in your Cartfile:

github "muukii/NextGrowingTextView"

Run carthage update to build the framework and drag the built NextGrowingTextView.framework into your Xcode project.

Author

muukii, [email protected]

License

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

FOSSA Status

Comments
  • updated .podspec file for beta release of cocoapods.

    updated .podspec file for beta release of cocoapods.

    While building project, Xcode gives an error called Resource.bundle was not found. This is typically happening when you type either pod install or pod update after dependency added to podfile. Therefore, I updated .podspec file and removed line stated as project resources. Because, project does not have any asset catalog or file.

    I've searched and found that this is only happening in 1.0.0 beta 6. On the other hand, this is a known issue in Cocoapods with the same version.

    opened by gokhanakkurt 11
  • How to use textViewDidChange with

    How to use textViewDidChange with "Revise APIs version" ?

    How can I upgrade this to newer one?

    let growingTextView: NextGrowingTextView
    
    growingTextView.delegates.textViewDidChange = { (growingTextView: NextGrowingTextView) in
      // Do something
    }
    
    opened by fatihyildizhan 6
  • Fix height calculation taking textContainerInset into account

    Fix height calculation taking textContainerInset into account

    This pull request fixes the height calculation when the user changes the textView's textContentInset, which by default is {top: 8, left: 0, bottom: 8, right: 0}. It includes the following changes:

    • Example code to demonstrate the fixed functionality: you can change the textContainerInset and run the example app to see how it changes the appearance of the text field.
    • Fixes the calculation of the frame used to draw the placeholder.
    • Uses the textContainerInset to calculate the minimum and maximum frame of the text field. Before contentInset was used, but this property is not exposed to the outside and by default it's UIEdgeInsetsZero
    • Sets the initial height of the textField to be the one we need to display a minimum text, and not the one we define when creating the view, either via -initWithFrame: or -initWithCoder: (from Interface builder).
    opened by gskbyte 4
  • Adds property alignsTextToTop which disables scrolls to bottom

    Adds property alignsTextToTop which disables scrolls to bottom

    When you have a text view which expands downwards, you enter a couple of lines and remove them, the text will be "aligned" to the bottom as the text view scrolls to the bottom. I have added a property alignsTextToTop which disables this behaviour and keeps the text at the top.

    opened by simonbs 4
  • XCode 10 GM and Swift 4.2 fail to build

    XCode 10 GM and Swift 4.2 fail to build

    /Users/joelaws/Workspace/kratos/Pods/NextGrowingTextView/NextGrowingTextView/NextGrowingInternalTextView.swift:38:157: 'UITextViewTextDidChange' has been renamed to 'UITextView.textDidChangeNotification'
    /Users/joelaws/Workspace/kratos/Pods/NextGrowingTextView/NextGrowingTextView/NextGrowingInternalTextView.swift:38:157: 'UITextViewTextDidChange' was obsoleted in Swift 4.2 (UIKit.NSNotification.Name)
    
    opened by jlaws 3
  • minHeight

    minHeight

    I set the property minNumberOfLines to be 3, But his height is still the height of a line

    I think the code for the bug is:

    private func updateMinimumAndMaximumHeight() {
        _minHeight = simulateHeight(1)
        _maxHeight = simulateHeight(maxNumberOfLines)
        fitToScrollView()
      }
    

    My test should be better like this:

      private func updateMinimumAndMaximumHeight() {
        _minHeight = simulateHeight(minNumberOfLines)
        _maxHeight = simulateHeight(maxNumberOfLines)
        fitToScrollView()
      }
    

    I hope to accept the comments, thank you very much.

    opened by fanglinwei 3
  • Bring back keyboardType

    Bring back keyboardType

    After the conversion to Swift 3, the keyboardType property somehow disappeared. This PR just brings it back.

    If you want, I can also do the preparation needed to bump the version to 0.8.2.

    Best regards!

    opened by gskbyte 3
  • fix textview scrollIndicator bug

    fix textview scrollIndicator bug

    GrowingTextView and InternalTextView both has scrollindicator

    get set method works on InternalTextView,

    so GrowingTextView scrollindicator did't get user's settings

    opened by sipdar 3
  • Fixed infinite recursion crash when custom typingAttributes are used

    Fixed infinite recursion crash when custom typingAttributes are used

    Hi, thanks for the a great component.

    This PR fixes EXC_BAD_ACCESS infinite recursion crash when using custom typingAttributes. Pretty simple and obvious :-)

    screen shot 2016-04-28 at 13 05 13

    opened by lukaskukacka 3
  • Enhancement request

    Enhancement request

    Hi @muukii ,

    Currently, the view is not resizing properly with new line characters: \n if you try to calculate the systemLayoutSizeFiitingSize(UILayoutFittingCompressedSize) after receiving the didChangeHeight delegates event.

    The reason is because it is being called before invalidating the intrinsic content size. In your code you have:

    self.delegates.didChangeHeight(self.frame.height)
    self.invalidateIntrinsicContentSize()
    

    You should instead switch these two lines as follows and the problem is fixed:

    self.invalidateIntrinsicContentSize()
    self.delegates.didChangeHeight(self.frame.height)
    

    Great component you have here. Keep up the good work :+1:

    opened by marcmatta 3
  • Not working on orientation change.

    Not working on orientation change.

    Hi, thanks for this great library. I'm using this growing textview in chat app, but on landscape it is not showing the textview proper. And also when rotate from portrait to landscape it creates same problem.

    opened by ambujshukla-cdn 2
  • Bug founded when reaching max line

    Bug founded when reaching max line

    when reaching max line, the textview changed its height to min line height. In NextGroingTextView.swift, line 409: containerSize = CGSize(width: actualTextViewSize.width, height: state.resolvedMinHeight) should be containerSize = CGSize(width: actualTextViewSize.width, height: state.resolvedMaxHeight)

    opened by zkfpk6 0
  • Storyboard support

    Storyboard support

    Is storyboard support completely gone from V2.0?

    Our app instantiated a NextGrowingTextView directly from storyboard and now after updating to v2 we get a fatal error that init(with coder:) is not implemented

    opened by morapelker 2
  • Placeholder get shrink

    Placeholder get shrink

    The Placeholder gets shrink when changes dynamically. I tried correcting it but it disturbs other attributes.

    Also how to we make multi-line placeholder for long text?

    Screenshot 2021-06-29 at 10 37 28 AM

    opened by Soniya1701 0
Releases(2.2.0)
Owner
Muukii
Swift & iOS - Working on creating apps and open-sourced libraries. I'm interested in Creating smooth and fancy UI, State-Management, Image Processing.
Muukii
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
An auto growing text input bar for messaging apps.

ALTextInputBar An auto growing text input bar for messaging apps. Written in Swift. ALTextInputBar is designed to solve a few issues that folks usuall

Alex Littlejohn 265 Nov 15, 2022
A SwiftUI TextField with a prompt (or placeholder) that floats above the text field when active or not empty. Requires iOS 15.

FloatingPromptTextField A prompt is the label in a text field that informs the user about the kind of content the text field expects. In a default Tex

Emilio Peláez 43 Nov 3, 2022
VKPinCodeView is simple and elegant UI component for input PIN. You can easily customise appearance and get auto fill (OTP) iOS 12 feature right from the box.

Features Variable PIN length Underline, border and custom styles The error status with / without shake animation Resetting the error status manually,

Vladimir Kokhanevich 95 Nov 24, 2022
Awesome TextField is a nice and simple libriary for iOS and Mac OSX

Awesome TextField is a nice and simple libriary for iOS and Mac OSX. It's highly customisable and easy-to-use tool. Works perfectly for any registration or login forms in your app.

Alexander Shoshiashvili 225 Nov 21, 2022
A Credit Amount and EMI User Interface build in Swift and SwiftUI

App Usage An iPhone application build in swift . Overview Supported on All iPhone Screen Sizes Dynamic Data following MVVM Design Pattern Used Transit

Mohammad Yasir 4 Apr 20, 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 Float Input View with smooth animation and supporting icon and seperator written with Swift

RSFloatInputView Features Smooth animation using CoreText Support optional left icon Support optional seperator Configurable padding, size, fonts and

null 103 Nov 13, 2022
A simple and easily customizable InputAccessoryView for making powerful input bars with autocomplete and attachments

InputBarAccessoryView Features Autocomplete text with @mention, #hashtag or any other prefix A self-sizing UITextView with an optional fixed height (c

Nathan Tannar 968 Jan 2, 2023
TTextField is developed to help developers can initiate a fully standard textfield including title, placeholder and error message in fast and convinient way without having to write many lines of codes

TTextField is developed to help developers can initiate a fully standard textfield including title, placeholder and error message in fast and convinient way without having to write many lines of codes

Nguyen Duc Thinh 7 Aug 28, 2022
Focus text field in SwiftUI dynamically and progress through form using iOS keyboard.

Focuser Focuser allows to focus SwiftUI text fields dynamically and implements ability move go through the form using Keyboard for iOS 13 and iOS 14.

Art Technologies 118 Dec 25, 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
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
⚡️ A library of widgets and helpers to build instant-search applications on iOS.

By Algolia. InstantSearch family: InstantSearch iOS | InstantSearch Android | React InstantSearch | InstantSearch.js | Angular InstantSearch | Vue Ins

Algolia 568 Jan 4, 2023
Declarative text styles and streamlined Dynamic Type support for iOS

StyledText StyledText is a library that simplifies styling dynamic text in iOS applications. Instead of having to use attributed strings every time yo

Blue Apron 233 Oct 18, 2022
A customisable view for entering arbitrary length pins, codes or passwords in iOS. Supports iOS 12 one time codes.

CBPinEntryView CBPinEntryView is a view written in Swift to allow easy and slick entry of pins, codes or passwords. It allows backspacing, dismissal o

Chris Byatt 183 Dec 5, 2022
A Swift framework for parsing, formatting and validating international phone numbers. Inspired by Google's libphonenumber.

PhoneNumberKit Swift 5.3 framework for parsing, formatting and validating international phone numbers. Inspired by Google's libphonenumber. Features F

Roy Marmelstein 4.7k Dec 29, 2022
DTTextField is a custom textfield with floating placeholder and error label

DTTextField Introduction DTTextField is a UITextField library with floating placeholder and error label. Floating placeholder inspired from JVFloatLab

Dhaval Thanki 310 Jan 5, 2023
A custom TextField with a switchable icon which shows or hides the password and enforce good password policies

PasswordTextField A custom TextField with a switchable icon which shows or hides the password and enforces good password policies, written in Swift. ⭐

Chris Jimenez 304 Dec 29, 2022