Can I detect iOS' "darken colors" setting? - ios

I noticed that my app doesn't look good when the "darken colors" iOS system setting is enabled. Some navigation buttons are white, some are darkened to gray.
Is there any way to detect if this setting is enabled?

Turns out it's quite easy to detect. Suppose the navigationBar is configured with a white tintColor. Just reading navigationBar.tintColor returns the adjusted color, in this case 80% white. We can use this color to set the navigationBar.titleTextAttributes.
For all tintable elements such as UIBarButtonItems, make sure to use template images only:
-[UIImage imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]

Related

Background colour does not change for dark/light change when transparency used MacOS swift

When I am using window background transparency in my app made for MacOS, when the system is switching from light to dark, or back, the colour change does not work.
This is how I change the transparency on the window background.
self.view.window?.backgroundColor = NSColor(named: "BackgroundColor")!.withAlphaComponent(WindowTransparency)
With the above code when I change the style from light to dark, it do not change.
When I am changing the code to
self.view.window?.backgroundColor = NSColor(named: "BackgroundColor")!
than the result is expected. With the system notification I call this line and it is perfectly changing the background color.
What can be the problem?

IOS NotificationContentExtension background color to match the theme

Hello
When creating NotificationContentExtension I can control the background color. I can also detect if the user has a dark or light theme.
I'd like to change the contentExtension background to either dark or light background to match the iPhone colors.
How can I get (preferably in runtime) the colors of the theme? Just to be clear - in the image attached you can see the notification has a "dark" header. I'd like to know the color of it exactly so I can match the content to be the same color. (instead of the current "black" color)
You can use UIColor.systemBackground
https://developer.apple.com/documentation/uikit/uicolor/ui_element_colors

Bar button item tint colors with iOS bold text settings

I've received a screenshot from my app by an older lady who seems to have activated "Bold text" in her iPhone settings.
Since I've never really looked at that before and my app does not support dynamic text (which seems to not be related) I was surprised to see that in this mode the tint colors I gave my bar button items are being ignored and they'll always show in standard iOS Nav bar button blue, this line of code does not have an effect anymore:
myBarButtonItem.tintColor = myColor
In my case the color indicates their state so that's a dealbreaker.
I know that I could detect whether the user has activated this setting (as indicated in the answer here Possible to detect Bold Text setting in Settings > Accessibility? ) and indicate the state by using different icons...
But is there any way around this and keep my tint colors in bold text mode?
Try with appearance
UIBarButtonItem.appearance().tintColor = yourcolor

How to create Semi-transparent buttons

If anyone could show me how to make a button similar to the one in the image below I would be really grateful!! I intend to use the button in XCode for Iphone/ IPad
I have no experience of this, but did you tried to make a e.g. 50% transparent (.GIF / .BMP) picture and set it as a background of the button?
OK so I solved this now, I set the alpha of my image to 0.7 with the following code
shootButton.alpha = 0.7;
And I also used photoshop's "Satin" effect to give it a more translucent effect.

iOS app that change whole app color theme (background, uibutton, icons color...) base on user selection

I have a requirement to make application that has color theme base on user selection
User selects an color at begining (in 8 available colors), that color will be applied for the whole app (background color, buttons, icons ....)
If I create images for each color, the app will have lots of images and can be heavy in size, and that approach not seem to be good one.
I tried to import images with 1 color and then change images color according to user-selected color, but got problem with some controls like slider, and also the image that is changed does not look good as photoshop one
Would u plz help me with good approach for this?
Make all the images one color (black probably), then let the user pick a color and save it to user defaults. Link all items that need to get the theme to the color from the user defaults. Then use the tintColor property of the UIImageView to themefy your app.
Method to tint any UIImageView:
- (void)tintImageView:(UIImageView *)imageView withTint:(UIColor *)tintColor
{
imageView.image = [imageView.image imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
[imageView setTintColor:tintColor];
}
Example use to tint Button:
[self tintImageView:self.button.imageView withTint:[UIColor blueColor]];
Example use to tint UIImageView:
[self tintImageView:self.imageView withTint:[UIColor blueColor]];
If you're using iOS7 you can take advantage of the tintColor property.
For images you need to be sure they are created using template option.
Please checkout this clear tutorial that will guide you to apply themes to different kind of controls in your app: Theming iOS Applications
You could probably be interested in trying Pixate Freestyle too, which basically allow you to apply styles like css does to your iOS app, that a pretty cool tool and I've found it very easy to use too.

Resources