0Pricing
SwiftUI Academy · Lekcja

Gradienty liniowe, radialne i kątowe

Proszę wypełniać widoki płynnymi przejściami kolorów.

Gradienty liniowe, radialne i kątowe to bezpłatna lekcja SwiftUI Academy na CoddyKit. To lekcja 2 z 4. Możesz przeczytać całą lekcję poniżej za darmo — a potem ćwiczyć ją interaktywnie w przeglądarce z wbudowanym edytorem kodu i tutorem AI dostępnym 24/7. To część ścieżki edukacyjnej SwiftUI Academy, a Twój postęp synchronizuje się między webem a aplikacją CoddyKit. Kurs SwiftUI Academy zawiera 4 lekcji w sumie.

Części tej lekcji nie zostały jeszcze przetłumaczone i są wyświetlane po angielsku.

What Is a Gradient?

A gradient blends smoothly between two or more colors. It adds depth and polish that a flat fill cannot. 🌈

Gradients Are Views Too

Just like Color, a LinearGradient is a view. You can place it directly or use it to fill a shape or background.

Your First LinearGradient

A LinearGradient flows colors along a straight line. Give it colors plus a start and end point to set the direction.

LinearGradient(
    colors: [.blue, .purple],
    startPoint: .top,
    endPoint: .bottom
)

Choosing Start & End Points

Points like .topLeading and .bottomTrailing aim the gradient diagonally. Swap them to change the angle of the blend.

startPoint: .topLeading
endPoint: .bottomTrailing

More Than Two Colors

Pass several colors and the gradient spreads them evenly across its length. Great for sunset-style backgrounds.

LinearGradient(
    colors: [.orange, .pink, .purple],
    startPoint: .leading,
    endPoint: .trailing
)

RadialGradient Glows Outward

A RadialGradient radiates from a center point outward in a circle. It is perfect for spotlights and soft glows.

RadialGradient(
    colors: [.yellow, .red],
    center: .center,
    startRadius: 5,
    endRadius: 120
)

Tuning the Radius

The startRadius and endRadius control how tight or wide the glow spreads. Bigger gaps mean smoother, slower fades.

AngularGradient Sweeps Around

An AngularGradient wraps colors around a center, like a color wheel. It creates a cool conical, swirling effect.

AngularGradient(
    colors: [.red, .green, .blue, .red],
    center: .center
)

Gradient as a Background

Attach a gradient with the background modifier to brighten any view behind your content. Instant visual lift.

Text("Hi")
    .padding()
    .background(LinearGradient(
        colors: [.blue, .cyan],
        startPoint: .top, endPoint: .bottom))

Shorthand Gradients

For a quick blend, call .gradient on any color. SwiftUI builds a subtle top-to-bottom gradient for you instantly.

Circle()
    .fill(Color.blue.gradient)

Pick the Right Gradient

Use linear for directional fades, radial for glows, and angular for wheels. Each gives a different mood to your UI. 🎨

Quick Check

Which gradient sweeps its colors around a center point?

Recap: Gradients

You now blend colors three ways: linear along a line, radial from a center, and angular around a wheel. Beautiful work!

Często zadawane pytania

Czy lekcja „Gradienty liniowe, radialne i kątowe” jest bezpłatna?

Tak — pełny tekst „Gradienty liniowe, radialne i kątowe” jest dostępny za darmo tutaj w sieci. Aby ćwiczyć ją interaktywnie (wbudowany edytor kodu i tutor AI dostępny 24/7) i odblokować resztę kursu SwiftUI Academy, przejdź na CoddyKit PRO. Kurs SwiftUI Academy zawiera 4 lekcji w sumie.

Co nauczysz się w „Gradienty liniowe, radialne i kątowe”?

Proszę wypełniać widoki płynnymi przejściami kolorów. Ćwiczysz SwiftUI Academy z praktycznym kodem, który uruchamiasz bezpośrednio w przeglądarce, a tutor AI dostępny 24/7 odpowiada na Twoje pytania podczas pracy nad lekcją.

Czy potrzebuję doświadczenia, aby zacząć SwiftUI Academy?

Nie wymagamy żadnego doświadczenia. SwiftUI Academy w CoddyKit jest strukturyzowany dla początkujących i zaawansowanych użytkowników, więc możesz zacząć tutaj lub od początku i uczyć się w swoim tempie. To lekcja 2 z 4.

Ile czasu zajmuje lekcja „Gradienty liniowe, radialne i kątowe”?

Większość lekcji CoddyKit trwa około 5–10 minut. Każda lekcja to mały, interaktywny krok, dzięki czemu robisz systematyczne postępy i zawsze wracasz dokładnie do tego samego miejsca — na webie i w aplikacji.

Czy mogę pisać i uruchamiać kod w tej lekcji SwiftUI Academy?

Tak. Każda lekcja SwiftUI Academy zawiera wbudowany edytor kodu, więc piszesz i uruchamiasz prawdziwy kod bezpośrednio w przeglądarce i od razu otrzymujesz sprzężenie zwrotne od AI — bez konfiguracji na komputerze.

Wszystkie lekcje w tym kursie

  1. Typ Color i kolory zasobów
  2. Gradienty liniowe, radialne i kątowe
  3. Wbudowane kształty
  4. Obrys, wypełnienie i overlay
← Powrót do SwiftUI Academy