When will an iOS application loads dark/light/any images from xcassets? - ios

I am in development of an iOS app which supports multiple themes. Some theme uses dark background colour and some uses light colour. Some of the default icons are not visible in dark/light backgrounds. I saw an option in xcassets to add images for different colour mode. My goal is to load an image from xcasset without using different icon name. eg: if I load an icon using ic-user, it should load appropriate image based on "SOME SETTINGS OR VALUE". Is this possible in iOS?, or is this feature only for macOS?

Automatically using different image asset appearances based on light/dark mode is only supported on macOS at this time.
It is rumoured that it will be added to iOS 13.
For the moment you will need to use code to load the required, individual, image based on your app's active theme.

Related

iOS launch screen for light and dark modes

I follow the instruction in RSP-12931: Native resolution not supported on iPAD Pro to create an iOS LaunchScreen for my Delphi app. Now, with iOS 13, the problem is that I need 2 variants of this launch screen, one for dark mode and another for light mode. How do I create a basic launch screen in XCode that shows a customized background color w/ logo image in dark/light modes?
This is all done inside an Asset Catalog.
For the logo, open your asset catalog and select the image. Now, select the Appearances drop down on the right, and select Any, Light, Dark.
The Asset Catalog will now let you add different images for Any (pre-iOS 13), Light and Dark for that particular image:
For the background color, you'll need to define a custom Color set inside your asset catalog.
Press the + button at the bottom of your list of assets, and select New Color set.
Select the Color set that appears in your assets and, again, adjust the Appearances dropdown to read Any, Light, Dark.
You can now provide different colors for each mode using the RGB sliders underneath the Appearances dropdown:
Now, inside your storyboard you'll be able to select your custom color, and it will adapt depending on the mode running on the device:
You can test this by flipping the Interface Style widget at the bottom of the Interface Builder window between light and dark mode:
After adding images in assets catalog with respect to appearance. If the changes are not reflected, uninstall the application and restart the device.

iOS 13 DarkMode and LaunchScreen - Fallback for iOS 10

I have a blue logo on the launchscreen.storyboard on white background.
For the new DarkMode introduced with iOS 13 I like to invert the colors, i.e. blue background and white logo.
As we know this can be done using named colors from the asset catalogues, which change depending on the traits of the device.
This is working totally fine in iOS 11 and up but shows this error when trying to support iOS 10:
Named colors do not work prior to iOS 11.0.
I tried making a view controller for the launchscreen scene in code and set the colors there using the #ifavailable clause, but the compiler says a launchscreen may not have a custom class associated with it.
I also thought of using different launchscreen storyboards depending on the iOS version but I couldn't find anything about how to.
Anything I can do about it?
How to solve this problem?
Thanks,
Felix
As suggested here, the solution is to use a dynamic image for the background instead:
Create 2 images with the flat colors for light and dark mode.
Import them in your Asset Catalog and define the “Any”/“Dark” appearances.
Add a UIImageView in the background of your Launch Screen with this image (“Scale to Fill”, constrained to container).
This will compile even if your deployment target is lower than iOS 11.0, and will display the appropriate color at launch.

Launch Images for Dark or Light Mode

How can I choose a different set of Launch images for Dark mode and for Light mode?
I have a LaunchImages set. When the application starts, an image is shown. For Light mode it seems good, however if I try to open my application on a device set to Dark mode (iOS 13), this image seems bad.
During the start application I can not use any code for dynamic changes and I have no options in XCode interface for managing it.
As the Launch Screen loads before the app starts executing, it would not be possible to change the launch images set programmatically.
However, in the Image Set tab, you can change the Appearance option to enable a different set of images for Light and Dark modes:
So, if you set this image in the Launch Screen Storyboard, the result would be as below:
On a side note, if the need is just to change the background color, not the images, you may set the Launch Screen Storyboard view background color to System Background Color and just use transparent PNG images.
Xcode 11 supports only storyboard Launch screen files. It means I
should use storyboards.
In storyboards we can use UIImageViews + images from .xcassets.
Assets support images with different variants: Light, Dark modes. You can apply constraints for positioning them on screen.
If you support iOS before 11.0 you can not use system dynamic colors for backgrounds of the screen view. In this case you put additional dynamic image to screen as background and apply leading, trailing, top and bottom constraints with negative values. Negative values are needed for covering Top and Bottom Bars. (I used -64px)
You need to add dark appearance for your asset, or for the asset color you are using, like in the image below:
You should do something like this to use light and dark mode images
Step 1 - Create image set in assets.xassets like this
Step 2 - Select Image select like this
Steps 3 - Change appearance to Any, Light , Dark like this
Add your images for any light and dark mode like this and use this image wherever you need it
Just for my experience, sometimes Launch image is changed when you erase your app, turn off your device and turn on again.

how to set app icon of app in xamarin.forms app for IOS

i have idea about how to set app icon image where we were putting all respective size icon images in resource folder.
in recent xamarin update there is no need to add multiple size images for splash screen using storyboard.
so my question is there something also for app icon also? so we need not to add multiple icon images??
any suggestion most welcome.
Add in Asset Catalog.Add an different sizes of icon and set that in infoplist.
Go to Assets.xcassets in Xamarin ios project, you will get a default AppIcon image set there which is by default using Xamarin logo.
Replace those images with you icons, make sure the resolutions your image follows the required resolutions/pixels for each (1x,2x&3x) type of images.

Is there is any iOS App which uses icon fonts for iOS Designs?

I have not even found a single article where they are talking about icon fonts for iOS Development. Is there is any reason for not using icon fonts in iOS Development?
Instead they prefer to use icons in pdf format.
Icon fonts are fine in iOS. You can mix images and different text fonts within an NSAttributedString and you can adjust the baseline for each so that you can deal with any vertical alignment issues.
Icons as images opens up the opportunity to alter tintColor and play with animations in a simple way, as well as producing multi-color icons that would not be possible with a simple font.

Resources