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
 

Vídeos

Abrir menu Fechar menu
  • Coleções
  • Todos os vídeos
  • Sobre

Mais vídeos

  • Sobre
  • Código
  • Build SwiftUI apps for tvOS

    Add a new dimension to your tvOS app with SwiftUI. We'll show you how to build layouts powered by SwiftUI and customize your interface with custom buttons, provide more functionality in your app with a context menu, check if views are focused, and manage default focus.

    To get the most out of this session, you should be comfortable with SwiftUI. For a primer, watch “Introducing SwiftUI: Building Your First App” and “SwiftUI On All Devices.”

    Recursos

    • Supporting Multiple Users in Your tvOS App
    • isFocused
    • prefersDefaultFocus(_:in:)
    • CardButtonStyle
    • Learn to Make Apps with SwiftUI
    • SwiftUI
    • Human Interface Guidelines: Designing for tvOS
      • Vídeo HD
      • Vídeo SD

    Vídeos relacionados

    WWDC20

    • What's new in SwiftUI

    WWDC19

    • Introducing SwiftUI: Building Your First App
    • SwiftUI On All Devices
  • Buscar neste vídeo...
    • 1:42 - CardButtonStyle

      Button(albumLabel, action: playAlbum)
          .buttonStyle(CardButtonStyle())
    • 2:24 - Custom Button Styles

      struct MyNewButtonStyle: ButtonStyle {
          func makeBody(configuration: Configuration) -> some View {
              configuration.label
                 .background(configuration.isPressed ? … : …) // Custom styling
          }
      }           
      
      Button(albumLabel, action: playAlbum)
          .buttonStyle(MyNewButtonStyle())
    • 3:19 - Context Menus

      AlbumView()
          .contextMenu {
              Button("Add to Favorites", action: addAlbumToFavorites)
              Button("View Artist", action: viewArtistPage)
              Button("Discover Similar Albums", action: viewSimilarAlbums)
          }
    • 5:47 - isFocused Environment Variable

      struct SongView: View {
          var body: some View {
              Button(action: playSong) {
                  VStack {
                      Image(albumArt)
                      DetailsView(...)
                  }
              }.buttonStyle(MyCustomButtonStyle())
          }
      }
      
      struct DetailsView: View {
          ...
          @Environment(\.isFocused) var isFocused: Bool
          var body: some View {
              VStack {
                  Text(songName)
                  Text(isFocused ? artistAndAlbum : artistName)
              }
          }
      }
    • 8:42 - Login Screen (Default Focus)

      var body: some View {
          VStack {
              TextField("Username", text: $username)
      
              SecureField("Password", text: $password)
      
              Button("Log In", action: logIn)
      
          }
      
      }
    • 8:51 - Default Focus

      @Namespace private var namespace
      @State private var areCredentialsFilled: Bool
      
      var body: some View {
          VStack {
              TextField("Username", text: $username)
                  .prefersDefaultFocus(!areCredentialsFilled, in: namespace)            
              SecureField("Password", text: $password)
      
              Button("Log In", action: logIn)
                 .prefersDefaultFocus(areCredentialsFilled, in: namespace)
          }
          .focusScope(namespace)
      }
    • 11:12 - Reset Focus

      @Namespace private var namespace
      @State private var areCredentialsFilled: Bool
      @Environment(\.resetFocus) var resetFocus
      
      var body: some View {
          VStack {
              TextField("Username", text: $username)
                  .prefersDefaultFocus(!areCredentialsFilled, in: namespace)            
              SecureField("Password", text: $password)
      
              Button("Log In", action: logIn)
                 .prefersDefaultFocus(areCredentialsFilled, in: namespace)
      
              Button("Clear", action: { 
                  username = ""; password = ""
                  areCredentialsFilled = false
                  resetFocus(in: namespace)
              })
          }
          .focusScope(namespace)
      }
    • 12:45 - Lazy Grids

      struct ShelfView: View {
          var body: some View {
              ScrollView([.horizontal]) {
                  LazyHGrid(rows: [GridItem()]) {
                      ForEach(playlists, id: \.self) { playlist in                
                          Button(action: goToPlaylist) {
                              Image(playlist.coverImage)
                                  .resizable()
                                  .frame(…)
                          }
                          .buttonStyle(CardButtonStyle())
                      }
                  }
              }
          }
      }

Developer Footer

  • Vídeos
  • WWDC20
  • Build SwiftUI apps for tvOS
  • 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