Change safe area color in dark mode - swift

I am using this code:
window?.safeAreaLayoutGuide.owningView?.backgroundColor =
UIColor(red:243.0/255.0, green:243.0/255.0, blue:243.0/255.0, alpha:1.0)
in SceneDelegate for change safe area color. And I want to change color of safe area for dark mode.
How can I do?

The best way to do this is to set up a Color Asset which has both light mode and dark mode variants included. This is simple to do, and once you have it set up, light/dark mode transitions will be handled automatically.
First, select your Assets.xcassets file, and right click anywhere within the left hand sidebar (under where it says "AccentColor" and "AppIcon"). This will open a popup menu; from there select "New Color Set." Now you should see a square named "Color" in the sidebar, and two squares labeled "Any Appearance" and "Dark" in the middle of the screen.
Next, click on one of those two squares. In the right hand sidebar, a color selector will pop up (with red, green, blue and opacity sliders, and the option to open the color selector panel). You can use these to set the RGB values you want for both light mode (the "Any Appearance" square) and dark mode.
Now that you've specified the color values, you still need a way to reference your new Color Asset from your code. This can be done with the UIColor(named: String) initializer. In Assets.xcassets, change the name from Color to whatever you want it to be called (I'll use "SafeAreaColor" as an example). Now, somewhere in your program (I usually do this in the Constants file) you should initialize the color:
let safeAreaColor = UIColor(named: "SafeAreaColor")
The last step is to incorporate this custom color into your existing code:
window?.safeAreaLayoutGuide.owningView?.backgroundColor = safeAreaColor
Now, your safe area should automatically change colors when the device shifts between Light and Dark mode.

Related

How can I adjust Flutter such that Fleksy recognizes colors and changes accordingly?

I'm making an app and I can't figure out what I need to change in order to make Fleksy recognize colors and change accordingly.
Fleksy is a keyboard app on devices that has a chameleon theme which changes according to the apps' color.
For instance, my app's main colors are white and red. Thus, in order to match general theme, I want Fleksy to change it's color to red whenever keyboard appears on the screen.
Is there something that I have to do within Flutter or there's a specific way to make this work?

How do I get the default color of Button text?

I am designing a UI in SwiftUI. There are a few buttons that I have customised with a rounded rectangle. I want the color of that rectangle to be the same as the color of the text - blue by default, and light grey in disabled mode.
At present I am hardcoding the colors. Is there some variable or function available to match the system settings for either of those colors?
The default color of a button is .accentColor. This works for both light & dark mode too:
Color.accentColor
I can't seem to find out how to get the disabled button color yet, but I'll update this if I find out.

Set tintColor in macCatalyst

In macOS Big Sur a multicolor accent color is allowed, no longer overwriting an app’s custom tint color (in theory).
This can be seen in a few system apps:
(images from this tweet)
However setting the tintColor property of a view, a window, or even UIView.appearance() still results in the default blue in macCatalyst. Not even setting onTintColor of a checkbox (UISwitch) has any effect.
Is this a bug or is there a correct way to do this?
You do it the same way you set tint color for a Watch app:
Open the app’s asset catalog.
Select the Editor > Add New Asset > Color Set menu item to add a new color set to the asset catalog.
In the app’s Build Settings, set the “Global Accent Color Name” to your color set’s name.
Apple’s WatchKit instructions are here, but it’s actually the same for all platforms: https://developer.apple.com/documentation/watchkit/setting_the_app_s_tint_color

GtkTreeView: how to stop selection bar overriding background-rgba setting

In my application the users can create a list of names associated with icons and colours. I've got the data stored in a GtkListStore and displayed using a GtkTreeView. The colour column is a GtkCellRendererText with the background-rgba property holding an opaque colour selected by the user. It looks like this.
However as you can see the selection bar hides the currently selected colour. The colour definition I've used in the CSS is alpha(#cce8ff, 0.5) and I know that the alpha is working because the colour fades out when I decrease the alpha value.
What I want is for the background colour in the cell to be visible through the selection highlight, although I could also live with the background colour blocking the selection highlight in that cell as long as the selected row was still clearly identified.
Is there some incantation I can use to achieve this? Or is this a bug in GTK3?
I'm using GTK 3.24.1 on Fedora 29. The application is written in Haskell using the gi-gtk binding.

Change the color of object at runtime in opengles

I want to change the color of my object dynamically in OpenGLES.I put one button on the screen and whenever I click the button, it will show the color picker(Here I am using HUE color picker). And I want to apply that selected color to my object.As I am importing CPP class to colorpickerview class, it will giving the so many errors.Can any one help me out.