SwiftでUILabelの文字色を設定するサンプル

2021年7月21日

書式
label.textColor = xxx
使用例

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.textColor = UIColor.red
}
}
import UIKit class ViewController: UIViewController { @IBOutlet weak var label: UILabel! override func viewDidLoad() { super.viewDidLoad() // 赤 label.textColor = UIColor.red } }
import UIKit
 
class ViewController: UIViewController {
 
    @IBOutlet weak var label: UILabel!
    
    override func viewDidLoad() {
        super.viewDidLoad()
            // 赤
        label.textColor = UIColor.red 
    }
}

 

Swift

Posted by arkgame