UISwitch

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

UIView

import UIKit
import PlaygroundSupport

class SwitchViewController : UIViewController {

    override func loadView() {

        // UI

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

        let uiswitch = UISwitch()
        uiswitch.isOn = true

        view.addSubview(uiswitch)

        // Layout

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

        self.view = view
    }

}

PlaygroundPage.current.liveView = SwitchViewController()
Btn training bbbdf557d2 Next iOS training: 25. Februar - 01. März 2019, Stuttgart
Btn about 5378472193 About me · Contact