Labels and text inside Text Field becoming white automatically for iOS 13 Dark mode

前端 未结 5 1884
既然无缘
既然无缘 2021-02-05 10:38

My app works fine for iOS versions below 13.0 but when i updated the device to iOS 13 and chose Dark Mode, the labels are going white(which were black earlier) automatically whi

相关标签:
5条回答
  • 2021-02-05 11:25

    It's because your label's text color is set Default. In dark mode default color for text label is white and for view is black

    0 讨论(0)
  • 2021-02-05 11:28
    TextField(placeholder, text: self.$value)
                    .colorScheme(.light)
    

    You should add colorScheme attribute to avoid the textfield from dark mode.

    0 讨论(0)
  • 2021-02-05 11:37

    Previously the default color of the UILabel was Black Color, but since iOS 13, the default value is LabelColor witch is a Semantic Color name from system UI Element Colors. To make it always black, change the color to black (not default). But be aware that the background color may change to black (from white) similarly.

    Also you can eliminate the dark mode entirely by setting the UserInterfaceStyle on main window:

    window!.overrideUserInterfaceStyle = .light
    

    Note: Window where in AppDelegate until iOS 13, and now it is in SceneDelegate.

    0 讨论(0)
  • 2021-02-05 11:38

    if you are using System Color than it will automatically change in dark mode. so you can use Custom Color in Application.

    Or you can set key User Interface Style and value Lightin Info.plist file.

    0 讨论(0)
  • 2021-02-05 11:44

    Change textField text color to black (don't leave default color) and place holder color using below code

    yourTextField.attributedPlaceholder = NSAttributedString(string: "Password", attributes: [NSAttributedString.Key.foregroundColor: UIColor.lightGray])
    
    0 讨论(0)
提交回复
热议问题