0Pricing
SwiftUI Academy · レッスン

複数行テキストと配置

行数制限、折り返し、テキストの配置を制御します。

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

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

When Text Gets Long

Short labels fit on one line, but paragraphs wrap. This lesson shows how to control wrapping, line limits, and alignment for longer text. 📝

Text Wraps by Default

SwiftUI wraps long text onto multiple lines automatically when there is room. You usually do not need to do anything for basic wrapping.

Text("A fairly long sentence that will wrap onto more than one line.")

Limiting Lines

The lineLimit modifier caps how many lines show. Extra text is truncated with an ellipsis, which is great for previews and cards.

Text(longBio)
    .lineLimit(2)

Truncation Mode

Control where the cut happens with truncationMode. Choose .tail, .head, or .middle depending on which part matters most.

Text(path)
    .lineLimit(1)
    .truncationMode(.middle)

Aligning Multiline Text

Use multilineTextAlignment to align wrapped lines left, center, or trailing. It only affects text that spans more than one line.

Text(quote)
    .multilineTextAlignment(.center)

Frame Versus Text Alignment

Remember the difference: frame alignment positions the whole block, while multilineTextAlignment arranges lines inside that block.

Centering a Block

To center a block and its lines, give it a wide frame and a center text alignment together. Both work as a pair.

Text(notice)
    .multilineTextAlignment(.center)
    .frame(maxWidth: .infinity)

Line Spacing

Add breathing room between lines with lineSpacing. A few extra points often makes dense paragraphs much easier to read.

Text(article)
    .lineSpacing(6)

Allowing Tight Layout

When space is tight, minimumScaleFactor lets text shrink instead of truncating, keeping the whole message visible.

Text(headline)
    .lineLimit(1)
    .minimumScaleFactor(0.7)

Fixed Size to Avoid Clipping

If wrapping text gets squeezed, fixedSize tells it to keep its ideal height so nothing gets unexpectedly clipped.

Text(message)
    .fixedSize(horizontal: false, vertical: true)

Putting It Together

Combine lineLimit, alignment, and spacing to craft readable cards. Small tweaks add up to a polished reading experience.

Quick Check

Which modifier aligns wrapped lines of text?

Lesson Recap

You shaped long text with lineLimit, truncation, alignment, and spacing. These tools keep paragraphs tidy and easy to read. 👍

よくある質問

「複数行テキストと配置」レッスンは無料ですか?

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

「複数行テキストと配置」で何を学びますか?

行数制限、折り返し、テキストの配置を制御します。 ブラウザで直接実行するハンズオンコードでSwiftUI Academyを演習し、24時間対応のAIチューターがレッスンを進める中での質問に答えます。

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

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

「複数行テキストと配置」レッスンにはどのくらい時間がかかりますか?

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

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

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

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

  1. フォント、太さ、色
  2. 複数行テキストと配置
  3. アセットから画像を読み込む
  4. SF Symbols の使用
← SwiftUI Academyに戻る