I have solved it with adding some key in info.plist.
The steps I followed are:
Opened my Project target's info.plist
file
Added a Key called NSAppTransportSecurity
as a Dictionary
.
Added a Subkey called NSAllowsArbitraryLoads
as Boolean
and set its value to YES
as like following image.
Clean the Project and Now Everything is Running fine as like before.
Ref Link: https://stackoverflow.com/a/32609970
EDIT:
OR In source code of info.plist
file we can add that:
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
<key>NSExceptionDomains</key>
<dict>
<key>yourdomain.com</key>
<dict>
<key>NSIncludesSubdomains</key>
<true/>
<key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
<false/>
</dict>
</dict>
</dict>
First, here is Apple's entry related to opting out of dark mode.
The content at this link is written for Xcode 11 & iOS 13:
Entire app via info.plist file (Xcode 12)
Use the following key in your info.plist file:
UIUserInterfaceStyle
And assign it a value of Light
.
The XML for the UIUserInterfaceStyle
assignment:
<key>UIUserInterfaceStyle</key>
<string>Light</string>
Apple documentation for UIUserInterfaceStyle
Entire app via info.plist in build settings (Xcode 13)
Entire app window via window property
You can set overrideUserInterfaceStyle
against the app's window
variable. This will apply to all views that appear within the window. This became available with iOS 13, so for apps that support previous versions, you must include an availability check.
Depending on how your project was created, this may be in the AppDelegate
or SceneDelegate
file.
if #available(iOS 13.0, *) {
window?.overrideUserInterfaceStyle = .light
}
Individual UIViewController or UIView
You can set overrideUserInterfaceStyle
against the UIViewController
s or UIView
's overrideUserInterfaceStyle
variable. This became available with iOS 13, so for apps that support previous versions, you must include an availability check.
Swift
override func viewDidLoad() {
super.viewDidLoad()
// overrideUserInterfaceStyle is available with iOS 13
if #available(iOS 13.0, *) {
// Always adopt a light interface style.
overrideUserInterfaceStyle = .light
}
}
For those poor souls in Objective-C
if (@available(iOS 13.0, *)) {
self.overrideUserInterfaceStyle = UIUserInterfaceStyleLight;
}
When set against the UIViewController
, the view controller and its children adopt the defined mode.
When set against the UIView
, the view and its children adopt the defined mode.
Apple documentation for overrideUserInterfaceStyle
Individual views via SwiftUI View
You can set preferredColorScheme
to be either light
or dark
. The provided value will set the color scheme for the presentation.
import SwiftUI
struct ContentView: View {
var body: some View {
Text("Light Only")
.preferredColorScheme(.light)
}
}
Apple documentation for preferredColorScheme
Credit to @Aron Nelson, @Raimundas Sakalauskas, @NSLeader and @rmaddy for improving this answer with their feedback.
Best Answer
Previously the
default
color of theUILabel
wasBlack Color
, but since iOS 13, the default value isLabelColor
witch is a Semantic Color name from system UI Element Colors. To make it always black, change the color toblack
(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:
Note: Window where in
AppDelegate
until iOS 13, and now it is inSceneDelegate
.