我正在尝试更改此视图的背景颜色,但无法做到这一点。我尝试将背景(Color.green)放在HStack、VSTack甚至ZStack上,但它不起作用,不确定我是否放在正确的位置。默认情况下,它采用手机或模拟器颜色,即白色,但我想应用自定义背景颜色我的 Xcode 版本是 11.5
struct HomePageView: View {
@State var size = UIScreen.main.bounds.width / 1.6
var body: some View {
GeometryReader{_ in
VStack {
HStack {
ZStack{
// main home page components here....
NavigationView{
VStack {
AssignmentDaysView()
}.background(Color.lairBackgroundGray)
.frame(width: 100, height: 100, alignment: .top)
.navigationBarItems(leading: Button(action: {
self.size = 10
}, label: {
Image("menu")
.resizable()
.frame(width: 30, height: 30)
}).foregroundColor(.appHeadingColor), trailing:
Button(action: {
print("profile is pressed")
}) {
HStack {
NavigationLink(destination: ProfileView()) {
LinearGradient.lairHorizontalDark
.frame(width: 30, height: 30)
.mask(
Image(systemName: …Run Code Online (Sandbox Code Playgroud)