Changing backgroundColor in Swift, Xcode 6

后端 未结 1 946
无人及你
无人及你 2021-01-25 00:56

I know the code to change the backgroundColor in iOS is something to this extent:

self.view.backgroundColor = UIColor.yellowColor()

But for som

相关标签:
1条回答
  • 2021-01-25 01:24

    You put your code in the wrong place.

    class ViewController: UIViewController {
    
        // This space is only for declarations.
    
        override func viewDidLoad() {
            super.viewDidLoad()
            // Do any additional setup after loading the view, typically from a nib.
    
            // Put this setup code in the viewDidLoad method.
            self.view.backgroundColor = UIColor.yellowColor()
        }
    
        override func didReceiveMemoryWarning() {
            super.didReceiveMemoryWarning()
            // Dispose of any resources that can be recreated.
        }
    }
    
    0 讨论(0)
提交回复
热议问题