C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
Next: We want to change the font property of our UITextField. We create a UIFont with a name and size argument.
UIFont: Some init methods for UIFont return an optional UIFont. So we can make sure they are valid with an if-let statement.
Optionals: if letExample UIFont, font property: Swift
//
// ViewController.swift
// ExampleTime7
//
// ...
//
import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Create UIFont with Times New Roman.
// ... Set size to 19.0.
let font = UIFont(name: "Times New Roman", size: 19.0)
// Use font on UITextField.
simpleText.font = font
}
@IBOutlet weak var simpleText: UITextField!
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}
}