Skip to content

JeaSungLEE/TextViewMaster

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

30 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

TextViewMaster

Version License: MIT Platform Swift 4.2

Introduce

image

Easy custom placeholder and growing textView

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.

Requirements

  • iOS9.0 or higher version
  • Swift4.2

Installation

Cocoapods

TextViewMaster is available through CocoaPods.

pod 'TextViewMaster'

Usage

import TextViewMaster

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 = TextViewMaster()
textViewMaster.delegate = self       
inputView.addSubview(textViewMaster)

If you have difficulty applying, please refer to the example folder.

Storyboard

  1. TextView Set class to "TextViewMaster".
  2. Set delegate to it's view controller

Delegate

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

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

Author

jeasungLEE

License

TextViewMaster is available under the MIT license.