iOS UILabel.appearance().textColor 不可用

iOS UILabel.appearance().textColor is not available

我正在尝试更改我应用中所有标签的默认文本颜色。我曾尝试使用 UILabel.appearance().textColor,但它对我不可用。有人可以建议我做错了什么吗?查了很多关于SO的问题,最新的是。根据描述,它是可用的。

如果我改变了背景颜色 - 就可以了。试图改变 tintColor - 没有效果。为什么?它是否已从 UIAppearance 协议中删除?

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterDelegate {
    var window: UIWindow?
    var smStore: SMStore?

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {

        // UIAppearance configuring
            let tintColor = UIColor.white
            //let backgroundColor = UIColor(red: 5, green: 72, blue: 149, alpha: 1)
            let backgroundColor = UIColor.black

            // Global tintColor
            window?.tintColor = tintColor

            // UIViews
            UIView.appearance().tintColor = tintColor
            UIView.appearance().backgroundColor = backgroundColor

            // UINavigationBars
            UINavigationBar.appearance().tintColor = tintColor
            UINavigationBar.appearance().backgroundColor = tintColor

            // UITableViews
            UITableView.appearance().backgroundColor = backgroundColor
            UITableViewCell.appearance().backgroundColor = backgroundColor
            UITableViewCell.appearance().tintColor = tintColor

            // UILabels
            UILabel.appearance().backgroundColor = UIColor.green
            ...
        }

Xcode9,Swift4.

只需输入即可编译。

UILabel.appearance().textColor = .red