这是一个SwiftUI问题,而不是UIKit问题。 :)
我正在尝试使用SwiftUI为导航栏标题设置其他字体。我怀疑这还不支持。这是我尝试过的:
var body: some View {
NavigationView {
.navigationBarTitle(Text("Dashboard").font(.subheadline), displayMode: .large)
}
}
无论我使用.font
设置如何,它都不会更改文本。我也尝试过设置自定义字体并删除displayMode
属性。
有人能使它正常工作吗?
答案 0 :(得分:1)
在SwiftUI中,目前我们无法直接更改dupli_df = pd.concat([df]*3, ignore_index=True)
# get all the column that are datetime and the length of the dataframe
l_col_datetime = dupli_df.select_dtypes('datetime').columns
len_df = len(df)
#add or remove a day depending on the slice
dupli_df.loc[len_df:2*len_df-1, l_col_datetime ] += pd.DateOffset(days=1)
dupli_df.loc[2*len_df:, l_col_datetime ] -= pd.DateOffset(days=1)
print(dupli_df)
Arrive Dept Val
0 2015-02-24 2015-02-25 1.450079
1 2015-02-25 2015-02-26 -1.478552
2 2015-02-26 2015-02-27 -0.596992
3 2015-02-25 2015-02-26 1.450079
4 2015-02-26 2015-02-27 -1.478552
5 2015-02-27 2015-02-28 -0.596992
6 2015-02-23 2015-02-24 1.450079
7 2015-02-24 2015-02-25 -1.478552
8 2015-02-25 2015-02-26 -0.596992
字体,但是您可以像这样更改NavigationBar的外观,
navigationBarTitle
我希望这会对您有所帮助。谢谢!
答案 1 :(得分:0)
如果您需要为SF系列使用新的Rounded face,可以使用此代码段
let design = UIFontDescriptor.SystemDesign.rounded
let descriptor = UIFontDescriptor.preferredFontDescriptor(withTextStyle: .largeTitle)
.withDesign(design)!
let font = UIFont.init(descriptor: descriptor, size: 48)
UINavigationBar.appearance().largeTitleTextAttributes = [.font : font]
答案 2 :(得分:0)
您需要的所有设置都在 init() 中。和他们一起玩,了解什么负责什么。几个小时前,这段代码帮助我理解了导航栏设置。我不记得我在哪里找到的。
struct ContentView: View {
init() {
// this is not the same as manipulating the proxy directly
let appearance = UINavigationBarAppearance()
// this overrides everything you have set up earlier.
appearance.configureWithTransparentBackground()
// this only applies to big titles
appearance.largeTitleTextAttributes = [
.font : UIFont.systemFont(ofSize: 20),
NSAttributedString.Key.foregroundColor : UIColor.white
]
// this only applies to small titles
appearance.titleTextAttributes = [
.font : UIFont.systemFont(ofSize: 20),
NSAttributedString.Key.foregroundColor : UIColor.white
]
//In the following two lines you make sure that you apply the style for good
UINavigationBar.appearance().scrollEdgeAppearance = appearance
UINavigationBar.appearance().standardAppearance = appearance
// This property is not present on the UINavigationBarAppearance
// object for some reason and you have to leave it til the end
UINavigationBar.appearance().tintColor = .white
}
var body: some View {
NavigationView {
ZStack {
Color.black
.edgesIgnoringSafeArea([.all])
NavigationLink(destination: ContentView2()) {
Text("push")
}
}
.navigationBarTitle("", displayMode: .inline)
.navigationBarBackButtonHidden(true)
}
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
struct ContentView2: View {
var body: some View {
ZStack {
Color.black
.edgesIgnoringSafeArea([.all])
NavigationLink(destination: ContentView()) {
Text("push")
}
}
.navigationBarTitle("My Custom White title", displayMode: .inline)
}
}
P。 S:代码取自here