How do you enable "Display Zoom" mode in SwiftUI preview? - swiftui

How do you enable "Display Zoom" mode in SwiftUI preview?
On a phone, you get to it from Settings, Display & Brightness, Display Zoom. Choose Standard or Zoomed.
On the simulator you can set it from Settings, Developer, Display Zoom.
But I don't see a way to set this in SwiftUI preview.

Sadly, many iOS features are not usable in a SwiftUI canvas preview. Display Zoom is one of them.

Related

Declare bottom zone in a SwiftUI navigation sidebar below a list

In the below screenshots (taken from the Apple Developer app), we can see that the Account button sticks to the bottom of the sidebar.
When the window is tall enough (left), the list doesn’t scroll, Account button’s background color has no difference. When the window is not tall enough (right), causing the list to scroll, Account button changes its background color to reveal the relationship.
The list's scroll position can not be probed. How can I declare the Account button in SwiftUI?
That app is a UIKit catalyst app and the sidebar uses scrollViewDidScroll which uses the contentSize to set a bottomButtonState which is passed into a child UIHostingController (so the account button can be SwiftUI) which I would assume switches between a clear or solid background.
We cant get the scroll info in SwiftUI however a possible workaround would be to add dummy 1 pixel high cell to the bottom of the list and using its onAppear to set a binding that is used in a bottom view to enable/disable a background colour and should achieve the same effect.

How to get the background color of the keyboard to make own toolbar over the keyboard?

what is the background color of the keyboard, so that I can make my own toolbar over the keyboard? Can I get the current color in the different modes?
You can use Digital Colour Meter App(Apps installed by default on Mac)

SwiftUI - TabView Light Mode UIColor Appears in Preview, not in Sim or Device

I am using Swift 5.3 on MacOS 11.01 and created a new "Multiplatform" app for iOS 14.2. I created custom color assets for light/dark modes but am having trouble getting the light mode background color to show on my TabView. The TabView dark mode background color appears just fine.
The light mode background color appears perfect in Xcode Preview, but when I run the app in the Sim or on my device, the Tab Bar background color is clear in light mode, but shows the correct color for dark mode.
I use the same color assets for coloring my NavigationView and both the light and dark mode colors appear correctly when the corresponding modes are selected.
Is there something obvious I am missing here with the latest SwiftUI 5.3 and color assets?
I am using the following code within .onAppear in the TabView
UITabBar.appearance().barTintColor = UIColor(named: "barBackground")
Note that "barBackground" is the custom color set I created to add a light/dark mode background colors to both the NavigationView and TabView.
Happy to furnish additional info if this isn't clear. Thanks!
It is a bit late to do it in .onAppear, appearance should be changed definitely before affected view is created, so do it in init
init() {
UITabBar.appearance().barTintColor = UIColor(named: "barBackground")
}

Android ActionBar vs ToolBar

Can you make Android new Toolbar to be shown with shadow like you could do with the old ActionBar?
Please refer to the image: Left is ActionBar and you can see it looks "floating" with shadow while the right one is ToolBar, how can you show it the same?
Use attibute android:elevetion=4dp on toolbar.

Can you implement a stacked ActionBar on a tablet?

I have implemented an ActionBar with my own custom icons. I have added tabs as well but I want these to appear below the ActionBar. At the moment they are displaying in the ActionBar. According to the Android Developers guide:
http://developer.android.com/guide/topics/ui/actionbar.html
when the screen is wide enough the tabs appear in the action bar
alongside the action buttons (such as when on a tablet, shown in
figure 7), while when on a narrow screen they appear in a separate bar
(known as the "stacked action bar", shown in figure 8)
Is it possible to implement a stacked action bar permanently so that the tabs are constantly displayed below the ActionBar across all devices?
If you want the same effect as in that image, you can use tabs. Here is a tutorial on how to implement them.