swiftui - 如何在 SwiftUI 中将图片添加到 iPad 导航视图的一侧?
问题描述
我有一个 TabBar 视图,它有一个导航视图作为选项卡之一。在 iPad 上,视图拥抱左侧,我想要在右侧旁边的图片/徽标(如图所示)。我将如何添加这个?
这是我的导航视图代码:
struct StartGameScreen: View {
@ObservedObject var processor = EventsProcessor.shared
@State var showGame = false
var body: some View {
NavigationView{
Form{
Section(header: Text("Teams")){
TextField("Home Team Name", text: $homeName)
TextField("Away Team Name", text: $awayName)
}
Section(header: Text("The Fixture")){
TextField("Location", text: $location)
DatePicker("Date of Fixture", selection: $date, displayedComponents: .date)
}
Section(header: Text("Officials")){
TextField("Referee", text: $referee)
TextField("Assistant Referee 1", text: $ar1)
TextField("Assistant Referee 1", text: $ar2)
TextField("4th Official", text: $fourthOfficial)
TextField("Televsion Match Official", text: $tmo)
}
Button("Start Game"){
self.showGame.toggle()
}
.fullScreenCover(isPresented: $showGame, content: {
ContentView()
})
}
.navigationBarTitle("New Game")
}
}
}
解决方案
你可以添加它
var body: some View {
NavigationView{
Form{
// ... other code
}
.navigationBarTitle("New Game")
Image("logo") // << here !!
}
}
推荐阅读
- azure - 在 Azure 上托管 ClickOnce 的问题
- macros - notepad++ 如何将两个宏分配给同一个键?
- flutter - 更改特定行中 listView 中的图标
- kotlin - 如何启动接收器,获取“lateinit 属性 notificationManager 尚未初始化”
- php - 如何使用 PHP 强制下载 PDF 文件?
- python - 如何等待第二个下拉列表基于第一个在 Python 中使用 Selenium 加载
- python - BOW(Bag Of Words)和TextBlob之间的区别
- javascript - 如何访问chart.js自定义工具提示界面中的类变量
- python - 序列化 json 对象内的自定义对象
- java - 创建 Java 类以接收 JSON 对象