英文:
Change font size of NavigationTitle in SwiftUI
问题
我想将navigationTitle
的字体大小更改为.footnote
。我尝试搜索,但所有的解决方案都与navigationBarTitle
有关。
以下是我的代码:
var body: some View {
NavigationView {
List {
CoverImageView()
.frame(height: 300)
.listRowInsets(EdgeInsets(top: 0, leading: 0, bottom: 0, trailing: 0))
}
.listStyle(PlainListStyle())
.navigationTitle(Text("Title").font(.footnote))
}
}
英文:
I wanted to change the font size of the navigationTitle
to .footnote
I tried to search but all the solutions i came up on internet were related to navigationBarTitle
Here is my Code:
var body: some View {
NavigationView {
List {
CoverImageView()
.frame(height: 300)
.listRowInsets(EdgeInsets(top: 0, leading: 0, bottom: 0, trailing: 0))
}
.listStyle(PlainListStyle())
.navigationTitle("Title")
//wanted to make "Title" appear as .footnote fontsize
}
}
答案1
得分: 0
Changing the appearance of the UINavigationBar
also seems to affect the navigationTitle
:
struct ContentView: View {
init() {
UINavigationBar.appearance().largeTitleTextAttributes = [.font: UIFont.preferredFont(forTextStyle: .footnote)]
UINavigationBar.appearance().titleTextAttributes = [.font: UIFont.preferredFont(forTextStyle: .footnote)]
}
var body: some View {
NavigationView {
List {
CoverImageView()
.frame(height: 300)
.listRowInsets(EdgeInsets(top: 0, leading: 0, bottom: 0, trailing: 0))
}
.listStyle(PlainListStyle())
.navigationTitle("Title")
}
}
}
(Code based on link)
I hope this helps.
英文:
Changing the appearance of the UINavigationBar
also seems to affect the navigationTitle
:
struct ContentView: View {
init() {
UINavigationBar.appearance().largeTitleTextAttributes = [.font : UIFont.preferredFont(forTextStyle: .footnote)]
UINavigationBar.appearance().titleTextAttributes = [.font : UIFont.preferredFont(forTextStyle: .footnote)]
}
var body: some View {
NavigationView {
List {
CoverImageView()
.frame(height: 300)
.listRowInsets(EdgeInsets(top: 0, leading: 0, bottom: 0, trailing: 0))
}
.listStyle(PlainListStyle())
.navigationTitle("Title")
}
}
}
(Code based on link)
I hope this helps.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论