๐Ÿ“ 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
Work in progress gallery of controls available to Catalyst apps using Optimized for Mac

Catalyst Controls Gallery Very simple work-in-progress demonstration of many common controls available to Mac Catalyst as of macOS 11. Provided moreso

Steven Troughton-Smith 163 Sep 18, 2022
Growing text view in SwiftUI

Growing text view in SwiftUI If you are planning to write a messaging feature or you are just a SwiftUI enthusiast, this repository can be interesting

Maciej Gomรณล‚ka 60 Jan 8, 2023
Fetch the star wars api from all the planets and list and show details using Swift UI and Combine

Star Wars Planets Fetch the star wars planet data by using stat war api, list and show details using SwiftUI and Combine frameworks ?? Swift UI Framew

null 1 Aug 10, 2022
A custom stretchable header view for UIScrollView or any its subclasses with UIActivityIndicatorView and iPhone X safe area support for content reloading. Built for iOS 10 and later.

Arale A custom stretchable header view for UIScrollView or any its subclasses with UIActivityIndicatorView support for reloading your content. Built f

Putra Z. 43 Feb 4, 2022
๐Ÿž A simple iOS photo and video browser with optional grid view, captions and selections written in Swift5.0

Introduction ?? MediaBrowser can display one or more images or videos by providing either UIImage objects, PHAsset objects, or URLs to library assets,

Kyle Yi 631 Dec 29, 2022
MZFormSheetPresentationController provides an alternative to the native iOS UIModalPresentationFormSheet, adding support for iPhone and additional opportunities to setup UIPresentationController size and feel form sheet.

MZFormSheetPresentationController MZFormSheetPresentationController provides an alternative to the native iOS UIModalPresentationFormSheet, adding sup

Michaล‚ Zaborowski 979 Nov 17, 2022
UIPheonix is a super easy, flexible, dynamic and highly scalable UI framework + concept for building reusable component/control-driven apps for macOS, iOS and tvOS

UIPheonix is a super easy, flexible, dynamic and highly scalable UI framework + concept for building reusable component/control-driven apps for macOS, iOS and tvOS

Mohsan Khan 29 Sep 9, 2022
UIStackView replica for iOS 7.x and iOS 8.x

TZStackView A wonderful layout component called the UIStackView was introduced with iOS 9. With this component it is really easy to layout components

Tom van Zummeren 1.2k Oct 10, 2022
Step-by-step progress view with labels and shapes. A good replacement for UIActivityIndicatorView and UIProgressView.

StepProgressView Step-by-step progress view with labels and shapes. A good replacement for UIActivityIndicatorView and UIProgressView. Usage let progr

Yonat Sharon 340 Dec 16, 2022
High performance and lightweight UIView, UIImage, UIImageView, UIlabel, UIButton, Promise and more.

SwiftyUI High performance and lightweight UIView, UIImage, UIImageView, UIlabel, UIButton and more. Features SwiftyView GPU rendering Image and Color

Haoking 336 Nov 26, 2022
BulletinBoard is an iOS library that generates and manages contextual cards displayed at the bottom of the screen

BulletinBoard is an iOS library that generates and manages contextual cards displayed at the bottom of the screen. It is especially well

Alexis (Aubry) Akers 5.3k Jan 2, 2023
โšก๏ธ 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 567 Dec 20, 2022
Modular and customizable Material Design UI components for iOS

Material Components for iOS Material Components for iOS (MDC-iOS) helps developers execute Material Design. Developed by a core team of engineers and

Material Components 4.6k Dec 29, 2022
Progress and Activity Indicators for iOS apps

Progress Indicators and Activity Views for iOS Apps Features Storyboard compatible, configure apprearance with the property inspector. fully animated,

Alexander Kasimir 101 Nov 13, 2022
StarryStars is iOS GUI library for displaying and editing ratings

StarryStars StarryStars is iOS GUI library for displaying and editing ratings Features StarryStars' RatingView is both IBDesignable and IBInspectable

Peter Prokop 175 Nov 19, 2022
Simple and highly customizable iOS tag list view, in Swift.

TagListView Simple and highly customizable iOS tag list view, in Swift. Supports Storyboard, Auto Layout, and @IBDesignable. Usage The most convenient

Ela Workshop 2.5k Jan 5, 2023
Twinkle is a Swift and easy way to make any UIView in your iOS or tvOS app twinkle.

Twinkle โœจ Twinkle is a Swift and easy way to make any UIView in your iOS or tvOS app twinkle. This library creates several CAEmitterLayers and animate

patrick piemonte 600 Nov 24, 2022
High performance Swift treemap layout engine for iOS and macOS.

Synopsis YMTreeMap is a high performance treemap layout engine for iOS and macOS, written in Swift. The input to YMTreeMap is a list of arbitrary numb

Yahoo 118 Jan 3, 2023
Blobmorphism is a brand new design language I've created to break free of the material overload in iOS, built in SwiftUI. Everything feels smooth and fluid.

Blobmorphism is a brand new design language I've created to break free of the material overload in iOS, built in SwiftUI. Everything feels smooth and fluid.

Ethan Lipnik 89 Nov 29, 2022