0Pricing
SwiftUI Academy · Урок

Шрифты, начертание и цвет

Оформляйте текст с помощью шрифта, fontWeight и foregroundStyle.

«Шрифты, начертание и цвет» — бесплатный урок SwiftUI Academy на CoddyKit. Это урок 1 из 4. Ты можешь прочитать весь урок бесплатно ниже — а потом практиковать его прямо в браузере с встроенным редактором кода и ИИ-репетитором 24/7. Это часть пути обучения SwiftUI Academy, и твой прогресс синхронизируется между веб-версией и приложением CoddyKit. Курс SwiftUI Academy содержит 4 уроков всего.

Части этого урока еще не переведены и отображаются на английском.

Styling Starts Here

A plain Text view shows words, but real apps style them. In this lesson you will set font, weight, and color to make text feel intentional. 🎨

The font Modifier

The font modifier picks a text style. Apple ships semantic sizes like title, headline, and body that adapt to the user automatically.

Text("Welcome")
    .font(.title)

Semantic Font Styles

Prefer semantic styles over fixed point sizes. Names like .largeTitle and .caption scale with the device and the user accessibility settings.

Text("Big").font(.largeTitle)
Text("Small").font(.caption)

Custom Point Sizes

Need an exact size? Pass .system(size:) with a number. It is handy for logos, but semantic styles are better for body text.

Text("Logo")
    .font(.system(size: 40))

Adding Weight

The fontWeight modifier sets how thick the strokes look. Try .bold for emphasis or .light for a softer, airier feel.

Text("Strong")
    .fontWeight(.bold)

Weight Inside font

You can also bake the weight right into the font call. This keeps related styling in one tidy place.

Text("Heavy")
    .font(.title.weight(.heavy))

Coloring Text

Use foregroundStyle to color text. Pass a Color like .red or a brand color, and the words pick up that tint instantly.

Text("Alert")
    .foregroundStyle(.red)

Semantic Colors

Reach for semantic colors like .primary and .secondary. They adapt to light and dark mode so your text stays readable everywhere.

Text("Hint")
    .foregroundStyle(.secondary)

Italic and Bold Shortcuts

SwiftUI offers quick toggles: .bold() and .italic(). They read cleanly and skip the longer modifier names.

Text("Note")
    .bold()
    .italic()

Chaining Modifiers

Modifiers stack top to bottom. Combine font, weight, and color on one Text to shape its full look in a single chain.

Text("Title")
    .font(.title)
    .bold()
    .foregroundStyle(.blue)

Order Can Matter

Most text modifiers commute, but order matters once layout enters. Keep styling first, then add padding or background later.

Quick Check

Which modifier sets the text color?

Lesson Recap

You styled text with font, fontWeight, and foregroundStyle. Lean on semantic styles and colors so your UI adapts beautifully. ✨

Часто задаваемые вопросы

Урок «Шрифты, начертание и цвет» бесплатный?

Да — полный текст урока «Шрифты, начертание и цвет» бесплатно доступен здесь в веб-версии. Чтобы практиковать его интерактивно (встроенный редактор кода и ИИ-репетитор 24/7) и разблокировать остальной курс SwiftUI Academy, подпишись на CoddyKit PRO. Курс SwiftUI Academy содержит 4 уроков всего.

Чему я научусь в уроке «Шрифты, начертание и цвет»?

Оформляйте текст с помощью шрифта, fontWeight и foregroundStyle. Ты практикуешь SwiftUI Academy с помощью реального кода, который запускаешь прямо в браузере, и ИИ-репетитор 24/7 отвечает на твои вопросы во время урока.

Нужен ли мне опыт, чтобы начать SwiftUI Academy?

Предыдущий опыт не требуется. SwiftUI Academy на CoddyKit структурирован для всех уровней — от новичков до продвинутых, поэтому ты можешь начать отсюда или с самого начала и учиться в своем темпе. Это урок 1 из 4.

Сколько времени занимает урок «Шрифты, начертание и цвет»?

Большинство уроков CoddyKit занимают около 5–10 минут. Каждый из них компактный и интерактивный, поэтому ты постоянно делаешь прогресс и продолжаешь с того же места в веб-версии и приложении.

Можно ли писать и запускать код в этом уроке SwiftUI Academy?

Да. Каждый урок SwiftUI Academy включает встроенный редактор кода, поэтому ты пишешь и запускаешь реальный код прямо в браузере и получаешь моментальную обратную связь от AI — локальная установка не требуется.

Все уроки этого курса

  1. Шрифты, начертание и цвет
  2. Многострочный текст и выравнивание
  3. Загрузка изображений из ресурсов
  4. Использование SF Symbols
← Назад к SwiftUI Academy