I create an app in XCode 10.2
.
Currently, Apple released a new OS version 13.2.3
, I update ios Version in a real device and I check my app in the real device.
not displaying text in my textField
How to fix this.
Anybody can help me.
I create an app in XCode 10.2
.
Currently, Apple released a new OS version 13.2.3
, I update ios Version in a real device and I check my app in the real device.
not displaying text in my textField
How to fix this.
Anybody can help me.
If your app not supporting Dark Mode:-
you can Disable dark mode in your entire app by adding the following key-value in your Info.Plist.
UIUserInterfaceStyle = Light
If your app supporting Dark Mode:-
In iOS 13 Dark mode Your Text color will not be visible. If you didn't set it. If you assign System colors dark mode and light colors will change automatically.
@IBOutlet weak var textFeild: UITextFeild!
override func viewDidLoad() {
super.viewDidLoad()
if #available(iOS 13.0, *) {
textFeild.textColor = .label // System Color
} else {
// Fallback on earlier versions
textFeild.textColor = .black
}
}
or For custom colors, you can use callback method in UIColor
@IBOutlet weak var textFeild: UITextFeild!
override func viewDidLoad() {
super.viewDidLoad()
if #available(iOS 13.0, *) {
let dynamicColor = UIColor { (traitCollection: UITraitCollection) -> UIColor in
if traitCollection.userInterfaceStyle == .dark {
return darkColor
} else {
return lightColor
}
}
UILabel().textColor = dynamicColor
} else {
// Fallback on earlier versions
UILabel().textColor = lightColor
}
}
You can set this in storyboard itself.
Change the appearance of your device to a light mode and see if the problem is solved. If yes, then you should set the textColor
of the text relative to the given appearance mode.
You can add new Color Set
in Assets.xcassets
, like this:
and the color will change automatically relative to the selected appearance mode.
Hope this will help you!