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
  • Principles of great widgets

    Explore the foundations of great widgets by keeping them relevant and customizable. Learn how to keep widgets up to date with timeline entries and TimelineReloadPolicies. Discover how to adapt your widget to different presentation environments and physical location. And lastly, find out how to create customizable widgets that someone can personalize to their liking.

    Ressources

    • Making a configurable widget
    • Keeping a widget up to date
      • Vidéo HD
      • Vidéo SD

    Vidéos connexes

    WWDC22

    • Complications and widgets: Reloaded

    WWDC21

    • Wednesday@WWDC21
    • What's new in SwiftUI
    • What's new in watchOS 8

    WWDC20

    • Add configuration and intelligence to your widgets
    • Build SwiftUI views for widgets
    • Design great widgets
    • Meet WidgetKit
  • Rechercher dans cette vidéo…
    • 15:46 - Xcode Previews for Widget Views with Color Scheme Overrides

      struct MyWidgetEntryView : View {
          var date: Date
      
          var body: some View {
              ZStack {
                  Rectangle().fill(BackgroundStyle())
                  VStack {
                      Text("Hello")
                  }
              }
          }
      }
      
      struct MyWidget_Previews: PreviewProvider {
          static var previews: some View {
              MyWidgetEntryView(date: Date())
                  .previewContext(WidgetPreviewContext(family: .systemSmall))
                  .environment(\.colorScheme, .dark)
          }
      }
    • 16:34 - Widget Partial Privacy Redactions - Banking Example

      struct MyWidgetEntryView : View {
      
          var body: some View {
              ZStack {
                  Rectangle().fill(BackgroundStyle())
                  VStack(alignment: .leading) {
                      Text("Balance")
                          .font(.largeTitle)
                          .fontWeight(.bold)
                          .foregroundColor(Color.blue)
                      Text("$128.45")
                          .privacySensitive()
                          .font(.title2)
                          .foregroundColor(Color.gray)
                  }
              }
          }
      }
    • 23:08 - WidgetBundle Example

      struct IndividualSymbolWidget : Widget {
          var body: some WidgetConfiguration {
          …
      }
      }
      
      struct StocksOverviewWidget : Widget {
          var body: some WidgetConfiguration {
          …
          }
      }
      
      @main
      struct MyWidgetBundle: WidgetBundle {
          var body: some Widget {
              // Order of these widgets defines the order in the Widget Gallery
              IndividualSymbolWidget()
              StocksOverviewWidget()
          }
      }
    • 25:43 - Static Widget Configuration Example

      @main
      public struct SampleWidget: Widget {
          public var body: some WidgetConfiguration {
              StaticConfiguration(kind: "com.sample.myStaticSampleWidgetKind",
                                  provider: Provider()) { entry in
                                      SampleWidgetEntryView(entry: entry)
                                  }
              .configurationDisplayName("My Widget")
              .description("This is an example widget.")
          }
      }
      
      public struct Provider: TimelineProvider {
          public func timeline(with context: Context,
                               completion: @escaping (Timeline<Entry>) -> ()) {
              let entry = SimpleEntry(date: Date())
              // TODO: Generate a timeline entry
              completion(timeline)
          }
      }
    • 25:55 - Intent Widget Configuration Example

      @main
      public struct SampleWidget: Widget {
          public var body: some WidgetConfiguration {
              IntentConfiguration(kind: "com.sample.myIntentSampleWidgetKind",
                                  intent: SampleConfigurationIntent.self
                                  provider: Provider()) { entry in
                                      SampleWidgetEntryView(entry: entry)
                                  }
              .configurationDisplayName("My Widget")
              .description("This is an example widget.")
          }
      }
      
      public struct Provider: IntentTimelineProvider {
          public func timeline(for configuration: SampleConfigurationIntent, with context: Context,
                               completion: @escaping (Timeline<Entry>) -> ()) {
              let entry = SimpleEntry(date: Date(), configuration: configuration)
              // generate a timeline
              completion(timeline)
          }
      }

Developer Footer

  • Vidéos
  • WWDC21
  • Principles of great widgets
  • 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