Skip to content

Latest commit

 

History

History
55 lines (40 loc) · 1.76 KB

README.md

File metadata and controls

55 lines (40 loc) · 1.76 KB

PlaceholderTextView

A UITextView that can show placeholder text when empty

Default Appearance

Screenshots

Quick Start

A simple TextView with placeholder text:

let aTextView = PlaceholderTextView(frame: CGRect(x: 0, y: 0, width: 200, height: 200))
aTextView.placeholder = "Type Here"
view.addSubview(aTextView)
aTextView.translatesAutoresizingMaskIntoConstraints = false
aTextView.leadingAnchor.constraint(equalTo: view.leadingAnchor).isActive = true
aTextView.topAnchor.constraint(equalTo: view.topAnchor).isActive = true
aTextView.widthAnchor.constraint(equalTo: view.widthAnchor).isActive = true
aTextView.heightAnchor.constraint(equalToConstant: 100.0).isActive = true

A text color can be assigned to .placeholderTextColor, or fully styled text can be assigned to the .attributedPlaceholder property.

ExpandingTextView

A PlaceholderTextView that resizes height to fit text entered

Default Appearance

Screenshots

Quick Start

A simple TextView with placeholder text:

let expandingTextView = ExpandingTextView(frame: CGRect(x: 0, y: 0, width: 200, height: 200))
expandingTextView.backgroundColor = .red
expandingTextView.textColor = .white
expandingTextView.font = .systemFont(ofSize: 18)
view.addSubview(expandingTextView)
expandingTextView.translatesAutoresizingMaskIntoConstraints = false
expandingTextView.leadingAnchor.constraint(equalTo: view.leadingAnchor).isActive = true
expandingTextView.topAnchor.constraint(equalTo: aTextView.bottomAnchor, constant: 20).isActive = true
expandingTextView.widthAnchor.constraint(equalTo: view.widthAnchor).isActive = true