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

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?

Related

Xamarin iOS change the default icon color to white in Light Mode

How do I display the dark mode icon while in Light mode on an iOS device? I have been searching this issue for months now and every post seems to come to dead end or the solutions just don't work. Using Xamarin 17.3 & VS 2022 and and developing an app for both Android & iOS. We have the Shell's background color (<Setter Property="Shell.BackgroundColor" Value="141B4D") which is a dark blue. The default, black icons (battery, time & etc.) don't show well with this background (its a company color and can't change it.) Android seems to handle this on its own and I didn't have to make any changes & the light icons show on the dark background in both Light & Dark modes. But on iOS in light mode the black icons display but cannot be seen. In dark mode the light icons show just fine.
Awhile back I tried a suggestion to to tell it, in the shared app, to use the dark mode icons in light mode.
<Shell.Resources>
<ResourceDictionary>
<Style x:Key="BaseStyle" TargetType="Element">
<Setter Property="Shell.BackgroundColor" Value="{AppThemeBinding Dark=Black, Light=#141B4D}" />
<Setter Property="Shell.ForegroundColor" Value="{AppThemeBinding Dark=White, Light=White}" />
But this doesn't work. So I really need some help in solving this. And if this is not the proper way to handle this a good alternative is welcomed.
Thanks
Based on your code, seems that you just want the text or icon in statusbar to be white if i understand correctly. So a simple way to achieve is to add the following code in AppDelegate:
public override bool FinishedLaunching(UIApplication app, NSDictionary options)
{
...
UIApplication.SharedApplication.StatusBarStyle = UIStatusBarStyle.LightContent;
return base.FinishedLaunching(app, options);
}
Also, you have to add one key in info.plist
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
Note: in Property List Editor, it will show View controller-based status bar appearance
Then in dark blue background, you can also see white icon. The following picture is in light mode.
Hope it works for you.

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

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.

Has the scrollviewTexturedBackgroundColor changed in iOS 5?

I am trying to make a table have a twitter-like background color. Please see: http://cocoacontrols.com/posts/how-to-build-the-twitter-ipad-user-experience
All they do is they use the scrollView Texture background and increase the alpha to 0.8 or so. This darkens it from the default apple shade. In my code, the following line of code works fine in iOS 4.3 and gives me a darker texture indeed. Moving to iOS 5, however, it's no longer darker, or for some reason it's not possible for me to darken the texture to be quite as dark. Is this a known problem?
Thanks!
conversationTable.backgroundColor =
[[UIColor scrollViewTexturedBackgroundColor] colorWithAlphaComponent:0.5];
Try to change the background color of the underlaying view (perhaps the window) to black.
The default window background color is (now?) white and so your code will do exactly the opposite.
self.window.backgroundColor = [UIColor blackColor];

Resources