Application NightTime Mode - ios

I have just finished creating my first application and would like to add some additional customisations to it. That is, in my settingsViewController I have added a switch which allows to set the colours to a nighttime mode. My questions is how can I actually get my application to do this.
Thanks in advance for your responses.

You can't expect this thing to be handled by iOS itself because its an app feature that you will have to implement.
You can change background colors to dark and all those UILabel UIButton UITextView dark colored as well to have a feature called dark mode(Dark theme) upon user selection.

Related

Dark mode don't update instantly

I have implemented dark mode in my iOS app, and while it works, the changes don't occur immediately. I think this has to do with the views not recreating themselves all the time like they do in android.
For instance, it doesn't work to go out from the app, then to settings and change theme, then back in the app again. The changes have only then occurred to Apple-related framework like alertControllers. To get dark mode to work I have to click around to a new view, then go back to the old view again.
I have tried adding dark mode code in the delegate, as I thought this would run every time you reenter your app, but it didn't.
So, any ideas on how to make this work? Is there for instance a delegate that is run every time I reenter the app, or can I have an observer to dark mode changes?
You could implement this method to "listen" to TraitCollection changes:
override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
// do whatever you want to do
}
Also, as Gergely mentioned, try to use xcassets for colors and images so they dynamically change depending on the current TraitCollection.
Alert view controllers update because they use responsive system colors for their text and background, which have versions for both light and dark mode by default and update automatically once the mode changes.
You can do the same with custom views if you use color and image assets. this is a nice overview of how to do things: Medium Article.
The official Apple documentation also has a nice overview of how to support dark mode: Supporting Dark Mode in Your Interface.

How to change the background color gradually just like the login UI of the Instagram app?

Recently, I have downloaded the Instagram app and found the login page of the app was so cool, especially the background color animation-- change one color to another color gradually.
I just want to know how to implement it.SCREEN SHOOT
Is it use a video which changes the color with a circle on the basis of the time?
Or some other methods? Can anyone tell me? Thanks!

How to set dark background for iOS10 today widget

I'm trying to workout how to set the background of an iOS 10 today extension/widget to what looks like a default dark mode. In the image below you can see the Weather Underground today widget and it is dark. There are a few apps with a dark background and they all look like the same background/style so I'm thinking it maybe a specific dark mode that can be set in code rather than just fiddling with the view controller color/transparency - no matter how much I try to set the color and transparency manually in the story board I can't even get close to this effect.
You can't do this. The apps that look like this, are not updated for iOS 10 yet. You can see that it hasn't been updated, because it is expanded without showing the "Show less"/"Show more" button.

What would be the most efficient way of implementing a dark mode in my application?

I have an application that I want to shift to night mode when a button is pressed. What would be the best way of doing that?
I was thinking of creating a class of light vs dark colors to use for certain labels as well as a notification firing when the button is pressed to notify all of the app to adopt the colors. Is there a better way of doing this?
So to set the color, you need to set the properties tintColor or barTintColor or something like this. But I think the real question of yours is, how you can effectifly switch between the two modes.
Your idea with the theme manager class that fires a notification is not that bad, another option would be to observe for theme changes. But firing a notification might be even better.
In this case you only need to listen for the theme-changed-notification inside you UI-subclasses and change their color if the notification fires. And don't forget to remove the NSNotificationCenter-observer in your dealloc :)
If you are building a web application you can use only CSS to implement a light- switch function.
This page looks exactly what you are looking for.
(It also has a CodePen demo.)

iPhone App Appearance Swap?

In my app I want to have an option available so that the user can alter the appearance of the app. This would simply be the visual style -- navigation bar, cell, font, and button images.
The user hits a button and then the app loads in the appropriate images or whatever.
What are the ways to approach this?
In iOS 5 and later you can use the UIAppearance class method appearance, which returns the appearance proxy for the receiver, and set it there. For instance, if you wanted to make all UIView background colors green, you would simply say:
[[UIView appearance] setBackgroundColor:[UIColor greenColor]];
This would, of course, only be good for the single user session. Once the app quit, you'd be back to white or whatever background color you set as the default.
The comment suggesting this SO question: Best way to apply a theme to an iPhone app provides a much more in-depth answer, and is probably more along the lines of what you're looking for.

Resources