NEW: My new book Pro SwiftUI is out now – level up your SwiftUI skills today! >>

What font / color is used for section headers?

Forums > SwiftUI

Hello,

Does any one know exctly what font is used by default in Section headers?

                Section(header: Text("AN AMAZING SECTION HEADER")) {

It looks like

.font(.system(size: 15, weight: .regular, design: .rounded))

but that seems not exactly the same font.

Thank you!

   

Hi, It looks a lot like

.font(.subheadline.smallCaps())
.foregroundColor(.secondary)

if not the same, i checked in apple design resources and it says SF Pro, Regular, 13pt.

   

Hi @flaneur7508! Off topic, noticed while helping you earlier that you often used font modifier .font(.system(size: 15, weight: .regular, design: .rounded))

Wouldn't be it much easier for you to create custom modifer and pass, say, size only. Saves a least some keystrokes while coding :). Well, if there is no good reason to do otherwise of course..

struct AppText: ViewModifier {
    var size: CGFloat

    func body(content: Content) -> some View {
        content
            .font(.system(size: size, weight: .regular, design: .rounded))
    }
}

extension View {
    func appText(_ size: CGFloat) -> some View {
        modifier(AppText(size: size))
    }
}

struct ContentView: View {
    var body: some View {
        VStack {
            Image(systemName: "globe")
                .imageScale(.large)
            Text("Hello, world!")
                .appText(25) // <- You will just type this instead that long code you used.
        }
        .padding()
    }
}

   

Hacking with Swift is sponsored by Essential Developer

SPONSORED From March 20th to 26th, you can join a FREE crash course for mid/senior iOS devs who want to achieve an expert level of technical and practical skills – it’s the fast track to being a complete senior developer!

Click to save your free spot now

Sponsor Hacking with Swift and reach the world's largest Swift community!

Reply to this topic…

You need to create an account or log in to reply.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.