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
 

Videos

Abrir menú Cerrar menú
  • Colecciones
  • Todos los videos
  • Información

Más videos

  • Información
  • Código
  • Create custom hover effects in visionOS

    Learn how to develop custom hover effects that update views when people look at them. Find out how to build an expanding button effect that combines opacity, scale, and clip effects. Discover best practices for creating effects that are comfortable and respect people's accessibility needs.

    Capítulos

    • 0:00 - Introduction
    • 2:35 - Content effects
    • 7:46 - Effect groups
    • 9:40 - Delayed effects
    • 12:09 - Accessibility

    Recursos

    • CustomHoverEffect
    • Human Interface Guidelines: Eyes
    • Forum: UI Frameworks
    • Destination Video
      • Video HD
      • Video SD

    Videos relacionados

    WWDC24

    • Discover RealityKit APIs for iOS, macOS, and visionOS

    WWDC23

    • Elevate your windowed app for spatial computing
  • Buscar este video…
    • 4:06 - Button with Scale Effect

      struct ProfileButtonView: View {
          var action: () -> Void = { }
          var body: some View {
              Button(action: action) {
                  HStack(spacing: 2) {
                      ProfileIconView()
                      ProfileDetailView()
                  }
              }
              .buttonStyle(ProfileButtonStyle())
          }
      
          struct ProfileButtonStyle: ButtonStyle {
              func makeBody(configuration: Configuration) -> some View {
                  configuration.label
                      .background(.thinMaterial)
                      .hoverEffect(.highlight)
                      .clipShape(.capsule)
                      .hoverEffect { effect, isActive, _ in
                          effect.scaleEffect(isActive ? 1.05 : 1.0)
                      }
              }
          }
      
          struct ProfileIconView: View {
              var body: some View {
                  Image(systemName: "person.crop.circle")
                      .resizable()
                      .scaledToFit()
                      .frame(width: 44, height: 44)
                      .padding(6)
              }
          }
      
          struct ProfileDetailView: View {
              var body: some View {
                  VStack(alignment: .leading) {
                      Text("Peter McCullough")
                          .font(.body)
                          .foregroundStyle(.primary)
                      Text("Switch profiles")
                          .font(.footnote)
                          .foregroundStyle(.tertiary)
                  }
                  .padding(.trailing, 24)
              }
          }
      }
    • 5:37 - Button with Clip and Scale Effects

      struct ProfileButtonView: View {
          var action: () -> Void = { }
          var body: some View {
              Button(action: action) {
                  HStack(spacing: 2) {
                      ProfileIconView()
                      ProfileDetailView()
                  }
              }
              .buttonStyle(ProfileButtonStyle())
          }
      
          struct ProfileButtonStyle: ButtonStyle {
              func makeBody(configuration: Configuration) -> some View {
                  configuration.label
                      .background(.thinMaterial)
                      .hoverEffect(.highlight)
                      .hoverEffect { effect, isActive, proxy in
                          effect.clipShape(.capsule.size(
                              width: isActive ? proxy.size.width : proxy.size.height,
                              height: proxy.size.height,
                              anchor: .leading
                          ))
                          .scaleEffect(isActive ? 1.05 : 1.0)
                      }
              }
          }
      
          struct ProfileIconView: View {
              var body: some View {
                  Image(systemName: "person.crop.circle")
                      .resizable()
                      .scaledToFit()
                      .frame(
                          width: 44,
                          height: 44
                      )
                      .padding(6)
              }
          }
      
          struct ProfileDetailView: View {
              var body: some View {
                  VStack(alignment: .leading) {
                      Text("Peter McCullough")
                          .font(.body)
                          .foregroundStyle(.primary)
                      Text("Switch profiles")
                          .font(.footnote)
                          .foregroundStyle(.tertiary)
                  }
                  .padding(.trailing, 24)
              }
          }
      }
    • 6:50 - Expanding Button with Ungrouped Fade

      struct ProfileButtonView: View {
          var action: () -> Void = { }
          var body: some View {
              Button(action: action) {
                  HStack(spacing: 2) {
                      ProfileIconView()
                      ProfileDetailView()
                          .hoverEffect { effect, isActive, _ in
                              effect.opacity(isActive ? 1 : 0)
                          }
                  }
              }
              .buttonStyle(ProfileButtonStyle())
          }
      
          struct ProfileButtonStyle: ButtonStyle {
              func makeBody(configuration: Configuration) -> some View {
                  configuration.label
                      .background(.thinMaterial)
                      .hoverEffect(.highlight)
                      .hoverEffect { effect, isActive, proxy in
                          effect.clipShape(.capsule.size(
                              width: isActive ? proxy.size.width : proxy.size.height,
                              height: proxy.size.height,
                              anchor: .leading
                          ))
                          .scaleEffect(isActive ? 1.05 : 1.0)
                      }
              }
          }
      
          struct ProfileIconView: View {
              var body: some View {
                  Image(systemName: "person.crop.circle")
                      .resizable()
                      .scaledToFit()
                      .frame(width: 44, height: 44)
                      .padding(6)
              }
          }
      
          struct ProfileDetailView: View {
              var body: some View {
                  VStack(alignment: .leading) {
                      Text("Peter McCullough")
                          .font(.body)
                          .foregroundStyle(.primary)
                      Text("Switch profiles")
                          .font(.footnote)
                          .foregroundStyle(.tertiary)
                  }
                  .padding(.trailing, 24)
              }
          }
      }
    • 8:19 - Expanding Button with Explicit Group

      struct ProfileButtonView: View {
          var action: () -> Void = { }
          @Namespace var hoverNamespace
          var hoverGroup: HoverEffectGroup {
              HoverEffectGroup(hoverNamespace)
          }
          var body: some View {
              Button(action: action) {
                  HStack(spacing: 2) {
                      ProfileIconView()
                      ProfileDetailView()
                          .hoverEffect(in: hoverGroup) { effect, isActive, _ in
                              effect.opacity(isActive ? 1 : 0)
                          }
                  }
              }
              .buttonStyle(ProfileButtonStyle(hoverGroup: hoverGroup))
          }
      
          struct ProfileIconView: View {
              var body: some View {
                  Image(systemName: "person.crop.circle")
                      .resizable()
                      .scaledToFit()
                      .frame(width: 44, height: 44)
                      .padding(6)
              }
          }
      
          struct ProfileDetailView: View {
              var body: some View {
                  VStack(alignment: .leading) {
                      Text("Peter McCullough")
                          .font(.body)
                          .foregroundStyle(.primary)
                      Text("Switch profiles")
                          .font(.footnote)
                          .foregroundStyle(.tertiary)
                  }
                  .padding(.trailing, 24)
              }
          }
      }
      
      struct ProfileButtonStyle: ButtonStyle {
          var hoverGroup: HoverEffectGroup?
          func makeBody(configuration: Configuration) -> some View {
              configuration.label
                  .background(.thinMaterial)
                  .hoverEffect(.highlight, in: hoverGroup)
                  .hoverEffect(in: hoverGroup) { effect, isActive, proxy in
                      effect.clipShape(.capsule.size(
                          width: isActive ? proxy.size.width : proxy.size.height,
                          height: proxy.size.height,
                          anchor: .leading
                      ))
                      .scaleEffect(isActive ? 1.05 : 1.0)
                  }
          }
      }
    • 9:13 - Expanding Button with Implicit Group

      struct ProfileButtonView: View {
          var action: () -> Void = { }
          var body: some View {
              Button(action: action) {
                  HStack(spacing: 2) {
                      ProfileIconView()
                      ProfileDetailView()
                          .hoverEffect { effect, isActive, _ in
                              effect.opacity(isActive ? 1 : 0)
                          }
                  }
              }
              .buttonStyle(ProfileButtonStyle())
              .hoverEffectGroup()
          }
      
          struct ProfileButtonStyle: ButtonStyle {
              func makeBody(configuration: Configuration) -> some View {
                  configuration.label
                      .background(.thinMaterial)
                      .hoverEffect(.highlight)
                      .hoverEffect { effect, isActive, proxy in
                          effect.clipShape(.capsule.size(
                              width: isActive ? proxy.size.width : proxy.size.height,
                              height: proxy.size.height,
                              anchor: .leading
                          ))
                          .scaleEffect(isActive ? 1.05 : 1.0)
                      }
              }
          }
      
          struct ProfileIconView: View {
              var body: some View {
                  Image(systemName: "person.crop.circle")
                      .resizable()
                      .scaledToFit()
                      .frame(
                          width: 44,
                          height: 44
                      )
                      .padding(6)
              }
          }
      
          struct ProfileDetailView: View {
              var body: some View {
                  VStack(alignment: .leading) {
                      Text("Peter McCullough")
                          .font(.body)
                          .foregroundStyle(.primary)
                      Text("Switch profiles")
                          .font(.footnote)
                          .foregroundStyle(.tertiary)
                  }
                  .padding(.trailing, 24)
              }
          }
      }
    • 10:51 - Expanding Button with Delayed Effect

      struct ProfileButtonView: View {
          var action: () -> Void = { }
          var body: some View {
              Button(action: action) {
                  HStack(spacing: 2) {
                      ProfileIconView()
                      ProfileDetailView()
                          .hoverEffect { effect, isActive, _ in
                              effect.animation(.default.delay(isActive ? 0.8 : 0.2)) {
                                  $0.opacity(isActive ? 1 : 0)
                              }
                          }
                  }
              }
              .buttonStyle(ProfileButtonStyle())
              .hoverEffectGroup()
          }
      
          struct ProfileButtonStyle: ButtonStyle {
              func makeBody(configuration: Configuration) -> some View {
                  configuration.label
                      .background(.thinMaterial)
                      .hoverEffect(.highlight)
                      .hoverEffect { effect, isActive, proxy in
                          effect.animation(.default.delay(isActive ? 0.8 : 0.2)) {
                              $0.clipShape(.capsule.size(
                                  width: isActive ? proxy.size.width : proxy.size.height,
                                  height: proxy.size.height,
                                  anchor: .leading
                              ))
                          }.scaleEffect(isActive ? 1.05 : 1.0)
                      }
              }
          }
      
          struct ProfileIconView: View {
              var body: some View {
                  Image(systemName: "person.crop.circle")
                      .resizable()
                      .scaledToFit()
                      .frame(
                          width: 44,
                          height: 44
                      )
                      .padding(6)
              }
          }
      
          struct ProfileDetailView: View {
              var body: some View {
                  VStack(alignment: .leading) {
                      Text("Peter McCullough")
                          .font(.body)
                          .foregroundStyle(.primary)
                      Text("Switch profiles")
                          .font(.footnote)
                          .foregroundStyle(.tertiary)
                  }
                  .padding(.trailing, 24)
              }
          }
      }
    • 12:50 - Expanding Button with Reusable Effects

      struct ProfileButtonView: View {
          var action: () -> Void = { }
          var body: some View {
              Button(action: action) {
                  HStack(spacing: 2) {
                      ProfileIconView()
                      ProfileDetailView()
                          .hoverEffect(FadeEffect())
                  }
              }
              .buttonStyle(ProfileButtonStyle())
              .hoverEffectGroup()
          }
      
          struct ProfileButtonStyle: ButtonStyle {
              func makeBody(configuration: Configuration) -> some View {
                  configuration.label
                      .background(.thinMaterial)
                      .hoverEffect(.highlight)
                      .hoverEffect(ExpandEffect())
              }
          }
      
          struct ExpandEffect: CustomHoverEffect {
              func body(content: Content) -> some CustomHoverEffect {
                  content.hoverEffect { effect, isActive, proxy in
                      effect.animation(.default.delay(isActive ? 0.8 : 0.2)) {
                          $0.clipShape(.capsule.size(
                              width: isActive ? proxy.size.width : proxy.size.height,
                              height: proxy.size.height,
                              anchor: .leading
                          ))
                      }.scaleEffect(isActive ? 1.05 : 1.0)
                  }
              }
          }
      
          struct FadeEffect: CustomHoverEffect {
              var from: Double = 0
              var to: Double = 1
      
              func body(content: Content) -> some CustomHoverEffect {
                  content.hoverEffect { effect, isActive, _ in
                      effect.animation(.default.delay(isActive ? 0.8 : 0.2)) {
                          $0.opacity(isActive ? to : from)
                      }
                  }
              }
          }
      
          struct ProfileIconView: View {
              var body: some View {
                  Image(systemName: "person.crop.circle")
                      .resizable()
                      .scaledToFit()
                      .frame(
                          width: 44,
                          height: 44
                      )
                      .padding(6)
              }
          }
      
          struct ProfileDetailView: View {
              var body: some View {
                  VStack(alignment: .leading) {
                      Text("Peter McCullough")
                          .font(.body)
                          .foregroundStyle(.primary)
                      Text("Switch profiles")
                          .font(.footnote)
                          .foregroundStyle(.tertiary)
                  }
                  .padding(.trailing, 24)
              }
          }
      }
    • 14:14 - Final Expanding Button with Accessibility Support

      struct ProfileButtonView: View {
          var action: () -> Void = { }
          var body: some View {
              Button(action: action) {
                  HStack(spacing: 2) {
                      ProfileIconView()
                      ProfileDetailView()
                          .hoverEffect(FadeEffect())
                  }
              }
              .buttonStyle(ProfileButtonStyle())
              .hoverEffectGroup()
          }
      
          struct ProfileButtonStyle: ButtonStyle {
              @Environment(\.accessibilityReduceMotion) var reduceMotion
              func makeBody(configuration: Configuration) -> some View {
                  configuration.label
                      .background {
                          ZStack(alignment: .leading) {
                              Capsule()
                                  .fill(.thinMaterial)
                                  .hoverEffect(.highlight)
                                  .hoverEffect(
                                      reduceMotion ? HoverEffect(FadeEffect()) : HoverEffect(.empty))
                              if reduceMotion {
                                  Circle()
                                      .fill(.thinMaterial)
                                      .hoverEffect(.highlight)
                                      .hoverEffect(FadeEffect(from: 1, to: 0))
                              }
                          }
                      }
                      .hoverEffect(
                          reduceMotion
                          ? HoverEffect(.empty)
                          : HoverEffect(ExpandEffect())
                      )
              }
          }
      
          struct ExpandEffect: CustomHoverEffect {
              func body(content: Content) -> some CustomHoverEffect {
                  content.hoverEffect { effect, isActive, proxy in
                      effect.animation(.default.delay(isActive ? 0.8 : 0.2)) {
                          $0.clipShape(.capsule.size(
                              width: isActive ? proxy.size.width : proxy.size.height,
                              height: proxy.size.height,
                              anchor: .leading
                          ))
                      }.scaleEffect(isActive ? 1.05 : 1.0)
                  }
              }
          }
      
          struct FadeEffect: CustomHoverEffect {
              var from: Double = 0
              var to: Double = 1
      
              func body(content: Content) -> some CustomHoverEffect {
                  content.hoverEffect { effect, isActive, _ in
                      effect.animation(.default.delay(isActive ? 0.8 : 0.2)) {
                          $0.opacity(isActive ? to : from)
                      }
                  }
              }
          }
      
          struct ProfileIconView: View {
              var body: some View {
                  Image(systemName: "person.crop.circle")
                      .resizable()
                      .scaledToFit()
                      .frame(
                          width: 44,
                          height: 44
                      )
                      .padding(6)
              }
          }
      
          struct ProfileDetailView: View {
              var body: some View {
                  VStack(alignment: .leading) {
                      Text("Peter McCullough")
                          .font(.body)
                          .foregroundStyle(.primary)
                      Text("Switch profiles")
                          .font(.footnote)
                          .foregroundStyle(.tertiary)
                  }
                  .padding(.trailing, 24)
              }
          }
      }

Developer Footer

  • Videos
  • WWDC24
  • Create custom hover effects in visionOS
  • 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