【问题标题】:How I change the weight from a text button?如何从文本按钮更改重量?
【发布时间】:2022-07-07 21:41:24
【问题描述】:

我有一个问题,我正在尝试从按钮更改字体粗细,但只有粗体有效,如果我更改为中等或常规,则不起作用。我使用的是 xcode 13。

代码

            Button("Login") {
            }.font(.title.bold())
            .font (.title3)
            .foregroundColor(.white)
            .padding(20)
            .frame(maxWidth: .infinity)
            .background(Color("ButtonColor"))
            .cornerRadius(4.0)
            

【问题讨论】:

  • 你试过.fontWeight(.medium)吗?

标签: swift swiftui


【解决方案1】:

像这样使用它

    Button("Login") {
    }
    .font(.title.weight(.heavy))   // << here !!

【讨论】:

    猜你喜欢
    • 2011-07-12
    • 1970-01-01
    • 2017-06-19
    • 2020-07-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多