0

I need an example code of how to implement the showExpansionTextWhenTruncated on Swift.

enter image description here

//
//  ViewController.swift
//  Two Buttons
//
//  Created by Ricardo E. Marrero Guzmán on 11/25/21.
//

import UIKit

class ViewController: UIViewController {
    @IBOutlet var label: UILabel!
    @IBOutlet var textField: UITextField!
    
    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view.
    }
    @IBAction func setTextButtonTapped(_ sender: UIButton) {
        label.showsExpansionTextWhenTruncated = true  // This line doesn't work
        label.text = textField.text
        
    }
    @IBAction func clearTextButtonTapped(_ sender: UIButton) {
        textField.text = .init()
    }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.