Skip to content

Instantly share code, notes, and snippets.

View alesplin's full-sized avatar

Alex Esplin alesplin

  • Fredericksburg, VA
View GitHub Profile
@alexpersian
alexpersian / UITextView+Truncated.swift
Last active August 21, 2023 03:22
Extension on UITextView that allows for the detection of truncation.
extension UITextView {
// Massive credit to Dave Delong for his extensive help with this solution.
/// Returns whether or not the `UITextView` is displaying truncated text. This includes text
/// that is visually truncated with an ellipsis (...), and text that is simply cut off through
/// word wrapping.
///
/// - Important:
/// This only works properly when the `NSLineBreakMode` is set to `.byTruncatingTail` or `.byWordWrapping`.
///
/// - Remark:
#!/bin/bash
n=$(tput cols)
for ((i=0; i<n; i++)); do
echo -n '='
done;
echo