Learn Courses My Dashboard

Cocoa How to adapt the text field to the View

Cocoa How to adapt the text field to the View even if the dimension of the view changes.

Thanks

@JoseBenito

Welcome to the community.

Can you post your code to show what you have tried to do?

Thank you very much for your quick response.
Here add two images of the view although the size changes the text does not change I would like to know if there is any function or class that does that automatically in Cocoa.

Thanks

Screenshot 2021-12-04 at 10.15.17

import Cocoa

class ViewController: NSViewController {

    @IBOutlet weak var label: NSTextField!
    
    
    override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.
        
        label.textColor = .blue
        
        
    }

    override var representedObject: Any? {
        didSet {
        // Update the view, if already loaded.
        }
    }

    
    
}

When you say “the text does not change” do you mean the Font or do you mean how do you make the time change?

I mean the size of the font, which fits the view.

OK now I understand what you are getting at.

Short answer is that I do not know. Perhaps someone else following this thread will be able to help.