0Pricing
SwiftUI Academy · レッスン

Dynamic Typeとスケーラブルフォント

レイアウトを崩さず大きな文字に対応します。

「Dynamic Typeとスケーラブルフォント」はCoddyKit上の無料SwiftUI Academyレッスンです。 これはレッスン2/4です。 下記で完全なレッスンを無料で読むことができます。その後、ブラウザ内の組み込みコードエディタと24時間対応のAIチューターでハンズオン演習できます。 これはSwiftUI Academy学習パスの一部であり、ウェブとCoddyKitアプリ全体で進捗が同期されます。 SwiftUI Academyコースには全4レッスンが含まれています。

このレッスンの一部はまだ翻訳されておらず、英語で表示されています。

What Is Dynamic Type?

Dynamic Type lets users pick their preferred text size system-wide. Your app should respect it, not force one fixed size. 🔤

Use Text Styles

Pick semantic text styles like .title or .body instead of fixed point sizes. These scale automatically with the user's setting.

Text("Welcome")
    .font(.title)
Text("Details here")
    .font(.body)

Why Not Fixed Sizes

A hard-coded .font(.system(size: 17)) ignores the user's choice and stays small. Text styles adapt; fixed numbers don't.

Text("Stuck small")
    .font(.system(size: 17))

Scaling Custom Fonts

Have a brand font? Use .font(.custom:size:relativeTo:) so it still scales with a chosen text style.

Text("Brand")
    .font(.custom("Avenir", size: 17, relativeTo: .body))

The ScaledMetric Wrapper

Need a spacing or image size to grow with text? @ScaledMetric scales any number alongside Dynamic Type.

@ScaledMetric var iconSize = 24
Image(systemName: "star").frame(width: iconSize)

Let Text Wrap

Big text needs room. Avoid lineLimit(1) on important labels, or long words will be cut off with an ellipsis.

Text(longTitle)
    .lineLimit(2)

Allow Tighter Fitting

When space is truly tight, minimumScaleFactor lets text shrink a little before truncating, keeping it readable.

Text(price)
    .minimumScaleFactor(0.7)

Preview Large Sizes

Use dynamicTypeSize in a preview to simulate the largest setting and catch broken layouts early.

#Preview {
    ContentView()
        .dynamicTypeSize(.accessibility3)
}

Cap the Range If Needed

You can limit how far text scales with dynamicTypeSize(...), but cap sparingly so you don't shut out users who need more.

VStack { }
    .dynamicTypeSize(...DynamicTypeSize.accessibility1)

Stacks Over Fixed Frames

Prefer flexible stacks over rigid heights. A fixed frame can clip large text, while a stack grows to fit.

Test at Both Ends

Check your app at the smallest and the largest Dynamic Type sizes. If both read well, most users in between will too.

Quick Check

You want a custom brand font to grow with the user's text size. What do you use?

Recap

You made text adapt: choose semantic text styles, scale custom fonts and metrics, let text wrap, and test the largest size. 👍

よくある質問

「Dynamic Typeとスケーラブルフォント」レッスンは無料ですか?

はい。「Dynamic Typeとスケーラブルフォント」の完全なテキストはこのウェブで無料で読めます。インタラクティブに演習し(組み込みコードエディタと24時間対応のAIチューター)、SwiftUI Academyコースの残りをアンロックするには、CoddyKit PROにアップグレードしてください。 SwiftUI Academyコースには全4レッスンが含まれています。

「Dynamic Typeとスケーラブルフォント」で何を学びますか?

レイアウトを崩さず大きな文字に対応します。 ブラウザで直接実行するハンズオンコードでSwiftUI Academyを演習し、24時間対応のAIチューターがレッスンを進める中での質問に答えます。

SwiftUI Academyを始めるのに経験は必要ですか?

事前経験は必要ありません。CoddyKitのSwiftUI Academyは初級者から上級者向けに構成されているため、ここから始めるか最初から始めて、自分のペースで進むことができます。 これはレッスン2/4です。

「Dynamic Typeとスケーラブルフォント」レッスンにはどのくらい時間がかかりますか?

ほとんどのCoddyKitレッスンは約5~10分かかります。各レッスンはコンパクトでインタラクティブなので、着実に進歩し、ウェブとアプリ全体で正確に前回の場所から再開できます。

このSwiftUI Academyレッスンでコードを書いて実行できますか?

はい。すべてのSwiftUI Academyレッスンに組み込みコードエディタが含まれているため、ブラウザでリアルコードを書いて実行し、即座のAIフィードバックを取得できます。ローカル設定は不要です。

このコースのすべてのレッスン

  1. VoiceOverとアクセシビリティラベル
  2. Dynamic Typeとスケーラブルフォント
  3. 文字列とString Catalogをローカライズする
  4. ライトモードとダークモードに対応する
← SwiftUI Academyに戻る