Swift Buttonのテキストのフォントを変えるサンプル

環境
Swift version 5.2.3 (swift-5.2.3-RELEASE)
Ubuntu 20.04.2 LTS

構文
Button(“xxx"){
xxx
}
.font(/*定義済みフォント*/)
ontの引数に「定義済みフォント」を指定します。

使用例

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
struct TestView: View {
var body: some View {
VStack{
Button("button"){
print("test")
}
.font(.system(.title, design: .serif))
}
}
}
struct TestView: View { var body: some View { VStack{ Button("button"){ print("test") } .font(.system(.title, design: .serif)) } } }
struct TestView: View {
    
    var body: some View {
        VStack{
            Button("button"){
                print("test")
            }
            .font(.system(.title, design: .serif))
        }
    }
}

 

Swift

Posted by arkgame