UIKit Framework - Snippets: Unterschied zwischen den Versionen

Aus Wikizone
Wechseln zu: Navigation, Suche
(Die Seite wurde neu angelegt: „== Base View == <syntaxhighlight lang="Swift"> import UIKit class SecondViewController: UIViewController { override func viewDidLoad() { super.vie…“)
 
Zeile 7: Zeile 7:
 
         super.viewDidLoad()
 
         super.viewDidLoad()
 
          
 
          
         view.backgroundColor = .red //UIColor.red
+
         view.backgroundColor = .red //Shortcut for UIColor.red
 
          
 
          
 
         let label = UILabel()
 
         let label = UILabel()

Version vom 4. Januar 2023, 08:59 Uhr

Base View

import UIKit

class SecondViewController: UIViewController {
    override func viewDidLoad() {
        super.viewDidLoad()
        
        view.backgroundColor = .red //Shortcut for UIColor.red
        
        let label = UILabel()
        label.text = "Hello"
        label.frame = CGRect(x: 0, y: 0, width: 100, height: 50)
        view.addSubview(label) // add the label to view. It's possible because label inherits view
        
    }
}