小编Mar*_*cB1的帖子

更改ViewController Swift的背景颜色?(单视图应用程序)

我在Swift(XCode 6.2)中创建了一个非常简单的单视图应用程序,它包含2个按钮"blackButton"和"whiteButton".单击blackButton后,它会将View的背景颜色更改为Black,并在单击whiteButton时将背景更改为白色.有谁能建议任何可能的方法来做到这一点?

ViewController.swift:

//beginning
import UIKit

class ViewController: UIViewController {

    @IBAction func blackButton(sender: AnyObject) {
    }
    @IBAction func whiteButton(sender: AnyObject) {
    }
    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }


}
Run Code Online (Sandbox Code Playgroud)

uiviewcontroller ios swift

21
推荐指数
2
解决办法
4万
查看次数

标签 统计

ios ×1

swift ×1

uiviewcontroller ×1