Created
June 29, 2020 13:39
-
-
Save alirp88/ab9544a8beefd17d7d0fb9e958838ab6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//: A UIKit based Playground for presenting user interface | |
import UIKit | |
import PlaygroundSupport | |
class MyViewController : UIViewController { | |
override func loadView() { | |
let view = UIView() | |
view.backgroundColor = .white | |
let label = UILabel() | |
label.translatesAutoresizingMaskIntoConstraints = false | |
label.text = "Hello World!" | |
label.textColor = .black | |
label.backgroundColor = .red | |
view.addSubview(label) | |
NSLayoutConstraint.activate([ | |
label.centerYAnchor.constraint(equalTo: view.centerYAnchor), | |
label.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 30), | |
view.trailingAnchor.constraint(equalTo: label.trailingAnchor, constant: 30) | |
]) | |
self.view = view | |
} | |
} | |
// Present the view controller in the Live View window | |
PlaygroundPage.current.liveView = MyViewController() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment