参考:Stanford Swift CS193P 10.Multithreading and Autolayout
private func updateFlipCountLabel() {
let attributes: [NSAttributedStringKey:Any] = [
.strokeWidth : 5.0
.strokeColor : black
]
let attributedString = NSAttributedString(
string: traitCollection.verticalSizeClass == .compact ? "Flips\n\(flipCount)" :
"flips: \(flipCount)",
attributes: attributes
)
flipCountLabel.attributedText = attributedString
}
override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
super.traitCollectionDidChange(previousTraitCollection)
updateFlipCountLabel()
}