Git Product home page Git Product logo

rstextviewmaster's Introduction

RSTextViewMaster

Version License: MIT Platform Swift 4.2

Intro

image

📱Easy custom placeholder and growing (iMessage-like) UITextView with customisation

You can easily adjust the color, font, and position of the placeholder. The height of the textview automatically changes every time you increase or decrease the line in the textview. You can specify a maxHeight property so the textview can start to scroll.

Requirements

  • iOS 9.0 or newer
  • Swift 4.2

Installation

Cocoapods

RSTextViewMaster is available through CocoaPods.

pod 'RSTextViewMaster'

Usage

import RSTextViewMaster

Set text

For the moment, please use textView.setText(text: String) to update textview's text. By using .text settler, the placeholder won't be removed. This will get fixed in future updates.

Customization

    isAnimate: Bool = true                                          
    maxLength: Int = 0                                              
    minHeight: CGFloat = 0                                          
    maxHeight: CGFloat = 0                                          

    placeHolder: String = ""                                        
    placeHolderFont: UIFont = UIFont.systemFont(ofSize: 17)         
    placeHolderColor: UIColor = UIColor(white: 0.8, alpha: 1.0)     
    placeHolderTopPadding: CGFloat = 0                              
    placeHolderBottomPadding: CGFloat = 0                           
    placeHolderRightPadding: CGFloat = 5                            
    placeHolderLeftPadding: CGFloat = 5                             

Programmatically

let textViewMaster = RSTextViewMaster()
textViewMaster.delegate = self       
inputView.addSubview(textViewMaster)

You will have to set constrains by code if you take this approach.

Storyboard

  1. TextView Set class to "RSTextViewMaster".
  2. Set delegate to it's view controller
  3. Set a height constraint but check "remove at runtime". This way Xcode won't bother you and the textview will work like magic

Check the demo for an example.

Delegate

RSTextViewMaster inherits from UITextViewDelegate. You can also use UITextViewDelegate by default. Added or modified functions

func growingTextView(growingTextView: RSTextViewMaster, shouldChangeTextInRange range:NSRange, replacementText text:String) -> Bool
func growingTextViewShouldReturn(growingTextView: RSTextViewMaster) 
func growingTextView(growingTextView: RSTextViewMaster, willChangeHeight height:CGFloat)
func growingTextView(growingTextView: RSTextViewMaster, didChangeHeight height:CGFloat)

Author

RSTextViewMaster is based on JeaSungLEE's work

License

RSTextViewMaster is available under the GNU license.

rstextviewmaster's People

Contributors

jeasunglee avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.