NSTextView/UITextView subclass with an expandable See More link. It helps avoid cluttering with too much information, by hiding some of it, allowing users to choose whether to display the hidden information. The hidden information is displayed by clicking on the See More link.


The main advantage of SeeMoreTextView is that it preserves text model intact fully accomplishing its functionality with the layout manager.


import SeeMoreTextView
var seeMoreTextView: SeeMoreTextView!
var scrollViewHeightConstraint: NSLayoutConstraint!

override func viewWillAppear() {

    seeMoreTextView = SeeMoreTextView(frame: .zero)
    seeMoreTextView.translatesAutoresizingMaskIntoConstraints = false
    let scrollView = CustomScrollView()
    scrollView.translatesAutoresizingMaskIntoConstraints = false
    scrollView.borderType = .noBorder
    scrollView.hasVerticalScroller = true
    scrollView.hasHorizontalScroller = false
    scrollView.documentView = seeMoreTextView
    scrollViewHeightConstraint = scrollView.heightAnchor.constraint(equalToConstant: 0)
    // See more text view's height change hook, which can be used for custom layout handling
    seeMoreTextView.onHeightChange = { sender in
        self.scrollViewHeightConstraint.constant = min(sender.height, 100)
        (sender.enclosingScrollView as! CustomScrollView).isEnabled = sender.isExpanded
        scrollView.centerXAnchor.constraint(equalTo: view.centerXAnchor),
        scrollView.topAnchor.constraint(equalTo: view.topAnchor, constant: 10),
        scrollView.widthAnchor.constraint(equalTo: seeMoreTextView.widthAnchor),
        scrollView.widthAnchor.constraint(equalToConstant: 400),

    // Full text to display
    let str = "On the other hand, ...."
    seeMoreTextView.contents = NSAttributedString(string: str, attributes: [
            .font: NSFontManager.shared.font(withFamily: "Helvetica", traits: [], weight: 5, size: 14)!
    // Number of lines to display in collapsed state
    seeMoreTextView.collapsedLineCount = 2

// NSScrollView subclass disabling scrolling on demand
class CustomScrollView: NSScrollView {
    var isEnabled = false
    override func scrollWheel(with event: NSEvent) {
        if isEnabled {
            super.scrollWheel(with: event)
        } else {
            nextResponder?.scrollWheel(with: event)


Swift Package as dependency in Xcode 11+

  1. Go to "File" -> "Swift Packages" -> "Add Package Dependency"
  2. Paste SeeMoreTextView repository URL into the search field:

  1. Click "Next"

  2. Ensure that the "Rules" field is set to something like this: "Version: Up To Next Major: 3.0.6"

  3. Click "Next" to finish

For more info, check out here.


Add the following to your Podfile:

platform :osx, '10.12'

target 'YOUR-TARGET' do
  pod 'SeeMoreTextView', :git => ''

Then run pod install.