Skip to content

Instantly share code, notes, and snippets.

@DDavis1025
Created June 16, 2020 21:11
Show Gist options
  • Save DDavis1025/433f7a9a9bfd079ffba7e8370ee71e2b to your computer and use it in GitHub Desktop.
Save DDavis1025/433f7a9a9bfd079ffba7e8370ee71e2b to your computer and use it in GitHub Desktop.
import Foundation
import UIKit
class TestTextView: UIViewController, UITextViewDelegate {
lazy var textView: UITextView = {
let tv = UITextView()
tv.text = "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum"
tv.backgroundColor = UIColor.lightGray
tv.layer.borderColor = UIColor.black.cgColor
tv.layer.borderWidth = 1.0
tv.layer.cornerRadius = 5
tv.isEditable = true
tv.textContainer.maximumNumberOfLines = 0
tv.textContainer.lineBreakMode = .byCharWrapping
tv.font = UIFont(name: "GillSans", size: 18)
return tv
}()
override func viewDidLoad() {
view.backgroundColor = UIColor.white
navigationController?.isToolbarHidden = true
self.textView.delegate = self
view.addSubview(self.textView)
setupTextViewConstraints()
view.bringSubviewToFront(self.textView)
}
func setupTextViewConstraints() {
textView.translatesAutoresizingMaskIntoConstraints = true
textView.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor).isActive = true
textView.leadingAnchor.constraint(equalTo: view.leadingAnchor).isActive = true
textView.trailingAnchor.constraint(equalTo: view.trailingAnchor).isActive = true
textView.bottomAnchor.constraint(equalTo: view.bottomAnchor).isActive = true
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment