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
  • Create engaging content for Swift Playgrounds

    Learn how you can build guided instructional content designed for Swift Playgrounds. Follow along with us as we explore how you can add a guide to a completed sample code project. We'll demonstrate how to add tasks to your learning center to show off relevant code and optional experiment tasks that encourage learners to extend the project with code of their own.

    Ressources

      • Vidéo HD
      • Vidéo SD

    Vidéos connexes

    WWDC22

    • Build your first app in Swift Playgrounds
    • WWDC22 Day 2 recap
  • Rechercher dans cette vidéo…
    • 1:27 - Dance Floor

      let numOfTiles = 100
      let squareLength = 150.0
      
          // Dance floor
          ForEach(0 ..< numOfTiles, id: \.self) { index in
              let i: CGFloat = CGFloat(index / 10)
              let j: CGFloat = CGFloat(index % 10)
      
              let x = (squareLength * i) - (squareLength)
              let y = (squareLength * j) - (squareLength * 2)
      
              Rectangle()
                  .frame(width: squareLength, height: squareLength)
                  .border(.black, width: 3)
                  .position(x: x, y: y)
                  .randomizedColorEffect(startAnimation: startParty)
          }
          .blur(radius: 15)
          .opacity(startParty ? 1.0 : 0.0)
    • 1:47 - Dance

      ForEach(data.creatures) { creature in
          Text(creature.emoji)
              .resizableFont()
              .animatedScalingEffect(startAnimation: startParty)
              .randomizedOffsetEffect(startAnimation: startParty,
                                      x: midX * 0.6,
                                      y: midY * 0.6)
              .animatedRotationEffect(startAnimation: startParty)
              .opacity(startParty ? 1.0 : 0.0)
      }
    • 2:08 - Disco Ball

      Text("🪩")
          .resizableFont()
          .animatedRotationEffect(startAnimation: startParty)
          .opacity(startParty ? 1 : 0)
    • 5:12 - Guidebook Directive

      @GuideBook(title: "Creature Party!", icon: icon.png, background: background.png, firstFile: CreatureDance.swift) {
          
      }
    • 5:28 - Welcome Message

      @WelcomeMessage(title: "Welcome to Creature Party!") {
      		In Creature Party, you'll take this app of dancing creatures to the next level with the help of colors, shapes, animations, and plenty of emoji!
      }
    • 5:37 - Guide and Step Directives

      @Guide {
              @Step(title: "Pump up the jams") {
                  
              }
          }
      }
    • 5:53 - Content and Media Directive

      @ContentAndMedia {
        	Tonight, the creatures are gonna party like it's 2022. 🐙💃🦝🕺🦦 
      }
    • 7:15 - Task Group Directive

      @TaskGroup(title: "Walkthroughs") {
      		Here are the walkthroughs! These will help explain all of the new code.                 
      }
    • 7:57 - First Walkthrough Task

      @Task(type: walkthrough, id: "partyMode", title: "Setting up the Party", file: CreatureDance.swift) {
      }
    • 8:44 - First Walkthrough Page

      @Page(id: "1.modifier", title: "") {
        	This is a [view modifier](https://developer.apple.com/documentation/swiftui/viewmodifier). Modifiers let you create unique versions of a view in SwiftUI. 
      }
    • 9:48 - Walkthrough Highlight

      ForEach(data.creatures) { creature in
      		Text(creature.emoji)
      			.resizableFont()
      			/*#-code-walkthrough(1.modifier)*/
      			.animatedScalingEffect(startAnimation: startParty)
      			/*#-code-walkthrough(1.modifier)*/
            .randomizedOffsetEffect(startAnimation: startParty,
            												x: midX * 0.6,
      				                      y: midY * 0.6)
            .animatedRotationEffect(startAnimation: startParty)
            .opacity(startParty ? 1.0 : 0.0)
      }
    • 11:56 - First Walkthrough extra pages

      @Page(id: "1.struct", title: "") {
        	Custom view modifiers are structures that contain code for explaining how to modify whatever view the given modifier is attached to.  
      }
      @Page(id: "1.body", title: "") {
        	The body method allows you to add custom view modifications. For example, here you're adding a scaling animation that grows and shrinks the `Creature` over a certain period of time. 
      }
    • 12:18 - Second Walkthrough Task

      @Task(type: walkthrough, id: "protocol", title: "A Little More on Protocols", file: CreatureDance.swift) {
          @Page(id: "2.protocol", title: "") {
            All custom view modifiers implement the `ViewModifier` protocol. 
          }
          @Page(id: "2.body", title: "") {
            The `ViewModifier` protocol requires all structures that implement it to write the `body(content:)` method.   
          }
          @Page(id: "2.usage", title: "") {
            After you've written content for your `body(content:)` method, you can use it on any view you want. Here you'll use it on each `Creature` to add a rotation animation.
          }
      }
    • 14:21 - First Experiment Task

      @TaskGroup(title: "Experiments") {
          Time to set this party off! You can use experiments to add some extra pazazz to the dance floor.
          @Task(type: experiment, id: "colors", title: "Dancing in the Strobe Light", file: CreatureDance.swift) {
      
          }
      }
    • 14:48 - First Experiment Page

      @Page(id: "3.code", title: "", isAddable: true) {
          ```
          .colorMultiply(creatureColor)
          ``` 
      }
    • 15:55 - Experiment Task Comment

      ForEach(data.creatures) { creature in
      		Text(creature.emoji)
          		.resizableFont()
              /*#-code-walkthrough(1.modifier)*/
              .animatedScalingEffect(startAnimation: startParty)
              /*#-code-walkthrough(1.modifier)*/
              .randomizedOffsetEffect(startAnimation: startParty,
              												x: midX * 0.6,
              												y: midY * 0.6)
              /*#-code-walkthrough(2.usage)*/
              .animatedRotationEffect(startAnimation: startParty)
              /*#-code-walkthrough(2.usage)*/
              .opacity(startParty ? 1.0 : 0.0)
              //#-learning-task(colors)
      }
    • 17:42 - Experiment Text

      @Page(id: "3.lights", title: "") {
        	Next, add some colors to the creatures so it looks like they're dancing under the lights! 
      }
    • 17:55 - Second Experiment Task

      @Task(type: experiment, id: "timer", title: "Switch it Up", file: CreatureDance.swift) {
          @Page(id: "4.lights", title: "") {
            	Now that you have some colors, you can add some code to change the color of the creatures using a timer. Let's add one!
          }
          @Page(id: "4.code", title: "", isAddable: true) {
              ```
              .onTapGesture {
                if let timer = timer {
                  timer.invalidate()
                  self.timer = nil
                } else {
                  creatureColor = Color.randomColor
                  timer = Timer.scheduledTimer(withTimeInterval: 2.0, repeats: true, block: { timer in
                                                                                             creatureColor = Color.randomColor
                                                                                            })
                }
              }
              ``` 
          }
      }

Developer Footer

  • Vidéos
  • WWDC22
  • Create engaging content for 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