Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS UILabel.appearance().textColor is not available

I am trying to change default text color for all labels in my app. I have tried to use UILabel.appearance().textColor, but it's not available for me. Can somebody advise what am I doing wrong? I have checked a lot of questions on SO, the latest one is this. And as per description it's available.

Xcode screenshot of UIAppearance autocompletions

If I changed background color - it works. Tried to change tintColor - no effect. Why? Was it removed from UIAppearance protocol?

@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
            ...
        }

Xcode 9, Swift 4.

like image 473
DJ-Glock Avatar asked Dec 05 '22 13:12

DJ-Glock


1 Answers

Just type it in. It compiles.

UILabel.appearance().textColor = .red
like image 143
rmaddy Avatar answered Dec 25 '22 05:12

rmaddy