View in English

  • Apple Developer
    • Get Started

    Explore Get Started

    • Overview
    • Learn
    • Apple Developer Program

    Stay Updated

    • Latest News
    • Hello Developer
    • Platforms

    Explore Platforms

    • Apple Platforms
    • iOS
    • iPadOS
    • macOS
    • tvOS
    • visionOS
    • watchOS
    • App Store

    Featured

    • Design
    • Distribution
    • Games
    • Accessories
    • Web
    • Home
    • CarPlay
    • Technologies

    Explore Technologies

    • Overview
    • Xcode
    • Swift
    • SwiftUI

    Featured

    • Accessibility
    • App Intents
    • Apple Intelligence
    • Games
    • Machine Learning & AI
    • Security
    • Xcode Cloud
    • Community

    Explore Community

    • Overview
    • Meet with Apple events
    • Community-driven events
    • Developer Forums
    • Open Source

    Featured

    • WWDC
    • Swift Student Challenge
    • Developer Stories
    • App Store Awards
    • Apple Design Awards
    • Apple Developer Centers
    • Documentation

    Explore Documentation

    • Documentation Library
    • Technology Overviews
    • Sample Code
    • Human Interface Guidelines
    • Videos

    Release Notes

    • Featured Updates
    • iOS
    • iPadOS
    • macOS
    • watchOS
    • visionOS
    • tvOS
    • Xcode
    • Downloads

    Explore Downloads

    • All Downloads
    • Operating Systems
    • Applications
    • Design Resources

    Featured

    • Xcode
    • TestFlight
    • Fonts
    • SF Symbols
    • Icon Composer
    • Support

    Explore Support

    • Overview
    • Help Guides
    • Developer Forums
    • Feedback Assistant
    • Contact Us

    Featured

    • Account Help
    • App Review Guidelines
    • App Store Connect Help
    • Upcoming Requirements
    • Agreements and Guidelines
    • System Status
  • Quick Links

    • Events
    • News
    • Forums
    • Sample Code
    • Videos
 

Vidéos

Ouvrir le menu Fermer le menu
  • Collections
  • Toutes les vidéos
  • À propos

Plus de vidéos

  • À propos
  • Code
  • Build a SwiftUI view in Swift Playgrounds

    Easily prototype and play around with SwiftUI views when you use them with Swift Playgrounds. We'll show you how to build a SwiftUI view in a Xcode-compatible playground, and explore tools to help you easily edit and preview your code.

    For more on Swift Playgrounds, check out our interactive challenge, “Swan's Quest”, and learn to build your own by watching “Create Swift Playgrounds Content for iPad and Mac”.

    Ressources

      • Vidéo HD
      • Vidéo SD

    Vidéos connexes

    WWDC20

    • Create Swift Playgrounds content for iPad and Mac
    • Swan's Quest, Chapter 1: Voices in the dark
    • Swan's Quest, Chapter 2: A time for tones
    • Swan's Quest, Chapter 3: The notable scroll
    • Swan's Quest, Chapter 4: The sequence completes
  • Rechercher dans cette vidéo…
    • 2:30 - Set up for SwiftUI

      import SwiftUI
      import PlaygroundSupport
    • 2:46 - Create a simple SwiftUI view

      struct ProgressView: View {
        
        var body: some View {
          Text("Hello, world!")
        }
        
      }
    • 3:12 - Show a SwiftUI live view

      PlaygroundPage.current.setLiveView(ProgressView())
    • 4:01 - Create a blue circle

      Circle()
      	.stroke(lineWidth: 25)
      	.foregroundColor(.blue)
    • 5:06 - Add some padding

      ProgressView().padding(150)
    • 5:30 - Create an empty ZStack

      ZStack { }
    • 5:51 - Add a text view

      Text("25%")
    • 9:24 - Make a struct public

      public struct ProgressView: View {
    • 9:38 - Make a view's body property public

      public var body: some View {
    • 9:45 - Make a view's initializer public

      public init(_ progress: Double = 0.3) {
    • 10:12 - Create another SwiftUI view

      struct Preview: View {
       
        var body: some View {
          // ...
        }
        
      }
    • 10:21 - Create a VStack of progress views

      VStack(spacing: 30) {
        ProgressView()
        ProgressView()
      }
    • 10:44 - Add padding to a view

      .padding(100)
    • 10:51 - Add a system background color to a view

      .background(Color(UIColor.secondarySystemBackground))
    • 11:19 - Initialize the Preview view

      Preview()
    • 11:35 - Use an environment modifier to preview dark mode

      .environment(\.colorScheme, .dark)
    • 12:12 - Create a state variable for tracking progress

      @State var progress = 0.25
    • 12:18 - Pass the progress to the ProgressView initializer

      ProgressView(progress)
    • 12:32 - Create a method for incrementing progress

      func increment() {
        self.progress += 0.25
      }
    • 12:40 - Add animation to the increment method

      func increment() {
        withAnimation {
          self.progress += 0.25
        }
      }
    • 12:52 - Create a button

      Button(action: increment)
    • 13:01 - Add a text label to a button

      Button(action: increment) {
        Text("Increment Progress")
      }

Developer Footer

  • Vidéos
  • WWDC20
  • Build a SwiftUI view in Swift Playgrounds
  • Open Menu Close Menu
    • iOS
    • iPadOS
    • macOS
    • tvOS
    • visionOS
    • watchOS
    • App Store
    Open Menu Close Menu
    • Swift
    • SwiftUI
    • Swift Playground
    • TestFlight
    • Xcode
    • Xcode Cloud
    • Icon Composer
    • SF Symbols
    Open Menu Close Menu
    • Accessibility
    • Accessories
    • Apple Intelligence
    • Audio & Video
    • Augmented Reality
    • Business
    • Design
    • Distribution
    • Education
    • Games
    • Health & Fitness
    • In-App Purchase
    • Localization
    • Maps & Location
    • Machine Learning & AI
    • Security
    • Safari & Web
    Open Menu Close Menu
    • Documentation
    • Downloads
    • Sample Code
    • Videos
    Open Menu Close Menu
    • Help Guides & Articles
    • Contact Us
    • Forums
    • Feedback & Bug Reporting
    • System Status
    Open Menu Close Menu
    • Apple Developer
    • App Store Connect
    • Certificates, IDs, & Profiles
    • Feedback Assistant
    Open Menu Close Menu
    • Apple Developer Program
    • Apple Developer Enterprise Program
    • App Store Small Business Program
    • MFi Program
    • Mini Apps Partner Program
    • News Partner Program
    • Video Partner Program
    • Security Bounty Program
    • Security Research Device Program
    Open Menu Close Menu
    • Meet with Apple
    • Apple Developer Centers
    • App Store Awards
    • Apple Design Awards
    • Apple Developer Academies
    • WWDC
    Read the latest news.
    Get the Apple Developer app.
    Copyright © 2026 Apple Inc. All rights reserved.
    Terms of Use Privacy Policy Agreements and Guidelines