IOS NotificationContentExtension background color to match the theme - ios

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

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?

How do I change the color of the push notification icon in flutter? [duplicate]

I tried making the small icon exactly 16x16, gray-scaled, nothing but gray and white (the gray color being hex value 616161), to create a silhouette of my application icon.
Yet no matter what it just shows up as a white/gray square in the notifications. What am I doing wrong?
(My min api is 21, assuming it is relevant)
Follow this link
First let’s understand the Android documentation which is as follows
“Update or remove assets that involve color. The system ignores all
non-alpha channels in action icons and in the main notification icon.
You should assume that these icons will be alpha-only. The system
draws notification icons in white and action icons in dark gray.”
Now this is easy to miss and I have seen many apps that are live in the app store with thousands of users who haven’t followed the mentioned guidelines.
So let me explain in detail how you can convert your notification icon to an Android friendly one with a few clicks.
In your favourite image editor open up your icon file. Convert all parts of the image that you don’t want to show to transparent pixels. All colors and non transparent pixels are displayed in white. Let us go through an example.
EDITED: Thanks #Andrey Patseiko for the tool
For notification you have to use different icons for different versions of android:
Notification notification = new Notification.Builder(context)
.setAutoCancel(true)
.setContentTitle("My notification")
.setContentText("Look, white in Lollipop, else color!")
.setSmallIcon(getNotificationIcon())
.build();
return notification;
Get notification icon on the basis of version
private int getNotificationIcon() {
boolean useWhiteIcon = (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP);
return useWhiteIcon ? R.drawable.icon_silhouette : R.drawable.ic_launcher;
}
Along with new features and capabilities, Android 5.0 includes a variety of system changes and API behavior changes. See the notification behavior changes.
Notifications are drawn with dark text atop white (or very light)
backgrounds to match the new material design widgets. Make sure that
all your notifications look right with the new color scheme. If your
notifications look wrong, fix them:
Use setColor() to set an accent color in a circle behind your icon image.
Update or remove assets that involve color. The system ignores all non-alpha channels in action icons and in the main notification icon.
You should assume that these icons will be alpha-only. The system
draws notification icons in white and action icons in dark gray.
So, basically you have to use silhouette icons as notification icon for API Level 21+

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

Can I detect iOS' "darken colors" setting?

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]

Change top bar background color iOS with AIR for Mobile (AS3)

Is it possible to change the background color of the top bar in iOS 6 with AIR for Mobile or can this only be done in native Objective-C?
What I mean:
http://shurl.be/uLwt
I've found a simple and easy solution for this.
Default the status bar style (UIStatusBarStyle) is set to UIStatusBarStyleBlackOpaque.
Just change the value to UIStatusBarStyleBlackTranslucent and set the background color of the SWF to the color you want the status bar to have.
So what I've done is just this:
Added the settings below in the Application descriptor
<key>UIStatusBarStyle</key>
<string>UIStatusBarStyleBlackTranslucent</string>
And changed the SWF background color
[SWF(backgroundColor="#ff6a00")]
Result:
VS
The solution for this in objective-c:
You can change it from, Target Settings -> Summery -> tint of status bar
Or
you can change it back to black from, info.plist -> set value for status bar style as opaque black style.

Resources