title
The title displayed next to a checkbox-style switch.
Declaration
var title: String? { get set }Mentioned in
Discussion
Set title only when the user interface idiom is UIUserInterfaceIdiom.mac; otherwise, a runtime exception occurs.
let showFavoritesAtTop = UISwitch()
showFavoritesAtTop.preferredStyle = .checkbox
if traitCollection.userInterfaceIdiom == .mac {
showFavoritesAtTop.title = "Always show favorite recipes at the top"
}The switch ignores title when the value of style isn’t UISwitch.Style.checkbox.