I'm beginning to try out SwiftUI
and I'm surprised that it doesn't seem to be straightforward to change the background color of a View
. How do you do this using SwiftUI
?
相关问题
- SwiftUI: UIImage (QRCode) does not load after call
- Android ContextMenu for View (Not Activity)
- In a UIViewControllerRepresentable, how can I pass
- How to change default background color for TChromi
- How do you preview a view containing a binding to
相关文章
- SwiftUI ForEach 'identified(by:)' is depre
- Set color of 'empty' area of ListView in A
- What the logcat message: “E/MoreInfoHPW_ViewGroup(
- SwiftUI automatically scroll to bottom in ScrollVi
- Type of expression is ambiguous without more conte
- SwiftUI - Vertical Centering Content inside Scroll
- NavigationView and NavigationLink on button click
- Do I need NO LOCK in my CREATE View query
You can Simply Change Background Color of a View:
and You can also use ZStack :
Use Below Code for Navigation Bar Color Customization
For
List
:All SwiftUI's
List
s are backed by aUITableView
in iOS. so you need to change the background color of the tableView. But sinceColor
andUIColor
values are slightly different, you can get rid of theUIColor
.Now you can use Any background (including all
Color
s) you wantAlso First look at this result:
As you can see, you can set the color of each element in the View hierarchy like this:
And the first one is
window
:The very common issue is we can not remove the background color of SwiftUI's
HostingViewController
(yet), so we can't see some of the views likenavigationView
through the views hierarchy. You should wait for the API or try to fake those views (not recommended).The code on Scene delegate in Swift UI
Content view background-color
like this