Я пишу сюда, потому что уже пытался добавить .padding(.top, value) // где значение — целое число, например 20. Дело в том, что это действует странно и добавляет отступы в верхнюю часть экрана (см. комментарий в блоке кода ниже).
Это весь файл ContentView.swift:
Код: Выделить всё
import SwiftUI
import WidgetKit
import UserNotifications
import UIKit
struct ContentView: View {
@StateObject var sharedVars = SharedVarsBetweenTabs()
var body: some View {
TabView {
HomeView()
.tabItem {
Label("Home", systemImage: "house.fill")
}
AppearanceView()
.tabItem {
Label("Appearance", systemImage: "paintbrush.fill")
}
QuotesView()
.tabItem {
Label("Quotes", systemImage: "quote.bubble.fill")
}
}
// This is where I tried putting .padding(.top, 20)
.environmentObject(sharedVars)
.accentColor(.blue)
.onAppear {
UITabBar.appearance().backgroundColor = UIColor.black
UITabBar.appearance().unselectedItemTintColor = UIColor.white
}
}
}
class SharedVarsBetweenTabs: ObservableObject {
@Published var colorPaletteIndex = 0
}
Код: Выделить всё
.frame(maxWidth: .infinity)
.padding()
.background(ColorPaletteView(colors: [colorPalettes[safe: sharedVars.colorPaletteIndex]?[0] ?? Color.clear])) // This corresponds to the blue int he screenshot
[img]https://i.stack. imgur.com/WHAWl.png[/img]
Подробнее здесь: https://stackoverflow.com/questions/781 ... o-tabitems