UILabel

UILabel.playground is an starting point to experiment with UILabel in an interactive playground:

UIView

import UIKit
import PlaygroundSupport

class LabelViewController : UIViewController {

    override func loadView() {

        // UI

        let view = UIView()
        view.backgroundColor = .white

        let label = UILabel()
        label.text = "Hello world!"

        view.addSubview(label)

        // Layout

        label.translatesAutoresizingMaskIntoConstraints = false
        NSLayoutConstraint.activate([
            label.topAnchor.constraint(equalTo: view.topAnchor, constant: 20),
            label.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 20),
        ])

        self.view = view
    }
    
}

PlaygroundPage.current.liveView = LabelViewController()
iOS training Next iOS training: 24. - 28. Juni 2019, Frankfurt am Main
Contact About me · Contact