「Swift」UILabelの背景色を設定するサンプル

2021年7月21日

書式
label.backgroundColor = 値
使用例

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
import UIKit
class ViewController: UIViewController {
@IBOutlet weak var label: UILabel!
override func viewDidLoad() {
super.viewDidLoad()
// 青
label.backgroundColor = UIColor.blue
}
}
import UIKit class ViewController: UIViewController { @IBOutlet weak var label: UILabel! override func viewDidLoad() { super.viewDidLoad() // 青 label.backgroundColor = UIColor.blue } }
import UIKit
 
class ViewController: UIViewController {
 
    @IBOutlet weak var label: UILabel!
    
    override func viewDidLoad() {
        super.viewDidLoad()
            // 青
        label.backgroundColor = UIColor.blue 
    }
}

 

Swift

Posted by arkgame