View in English

  • Apple 开发者
    • 入门汇总

    探索“入门汇总”

    • 概览
    • 学习
    • Apple Developer Program

    及时了解最新动态

    • 最新动态
    • 开发者你好
    • 平台

    探索“平台”

    • Apple 平台
    • iOS
    • iPadOS
    • macOS
    • Apple tvOS
    • visionOS
    • watchOS
    • App Store

    精选

    • 设计
    • 分发
    • 游戏
    • 配件
    • 网页
    • Home
    • CarPlay 车载
    • 技术

    探索“技术”

    • 概览
    • Xcode
    • Swift
    • SwiftUI

    精选

    • 辅助功能
    • App Intents
    • Apple 智能
    • 游戏
    • 机器学习与 AI
    • 安全性
    • Xcode Cloud
    • 社区

    探索“社区”

    • 概览
    • “与 Apple 会面交流”活动
    • 社区主导的活动
    • 开发者论坛
    • 开源

    精选

    • WWDC
    • Swift Student Challenge
    • 开发者故事
    • App Store 大奖
    • Apple 设计大奖
    • Apple Developer Centers
    • 文档

    探索“文档”

    • 文档库
    • 技术概述
    • 示例代码
    • 《人机界面指南》
    • 视频

    发布说明

    • 精选更新
    • iOS
    • iPadOS
    • macOS
    • watchOS
    • visionOS
    • Apple tvOS
    • Xcode
    • 下载

    探索“下载”

    • 所有下载
    • 操作系统
    • 应用程序
    • 设计资源

    精选

    • Xcode
    • TestFlight
    • 字体
    • SF Symbols
    • Icon Composer
    • 支持

    探索“支持”

    • 概览
    • 帮助指南
    • 开发者论坛
    • “反馈助理”
    • 联系我们

    精选

    • 《开发者账户帮助》
    • 《App 审核指南》
    • 《App Store Connect 帮助》
    • 即将实行的要求
    • 协议和准则
    • 系统状态
  • 快速链接

    • 活动
    • 新闻
    • 论坛
    • 示例代码
    • 视频
 

视频

打开菜单 关闭菜单
  • 专题
  • 所有视频
  • 关于

更多视频

  • 简介
  • 代码
  • Prepare your app for Accessibility Nutrition Labels

    Learn how to prepare your app for Accessibility Nutrition Labels by supporting essential accessibility features. Discover how you can enhance interaction methods like VoiceOver and Voice Control by properly configuring accessibility labels, traits, and values for custom controls and gestures. Find out how you can support larger text sizes using Dynamic Type, and prevent content truncation with flexible layouts. And learn how to make your app design more inclusive by adopting Dark Mode, responding to preferences like Differentiate Without Color, and ensuring sufficient contrast.

    章节

    • 0:01 - Welcome
    • 2:18 - Interaction methods
    • 18:04 - Larger text
    • 26:27 - Color
    • 32:55 - Next steps

    资源

    • Overview of Accessibility Nutrition Labels
    • Accessibility
    • Learn more about designing for accessibility
      • 高清视频
      • 标清视频

    相关视频

    WWDC25

    • 针对辅助功能标签评估你的 App

    WWDC24

    • 了解 SwiftUI 中的辅助功能
    • 动态字体体验入门
  • 搜索此视频…
    • 6:39 - Add descriptive accessibility labels

      // Add descriptive accessibility labels
      
      // SwiftUI
      Image(landmark.backgroundImageName)
        .accessibilityLabel("Vibrant cherry blossoms frame a snow-capped mountain rising in the background.")
      
      
      // UIKit
      let imageView = UIImageView(image: UIImage(named: landmark.backgroundImageName))
      imageView.isAccessibilityElement = true
      imageView.accessibilityLabel = "Vibrant cherry blossoms frame a snow-capped mountain rising in the background."
    • 7:43 - Add alternate labels for Voice Control

      // Add alternate labels for Voice Control
      
      Button {
        addFavorite()
      } label: {
        Image(systemName: "heart")
      }
      .accessibilityLabel("Favorite")
      .accessibilityInputLabels(["Favorite", "Heart", "Like", "Love"])
    • 8:23 - Set accessibility traits to match an element’s role

      // Set accessibility traits to match an element’s role
      
      // SwiftUI
      Text("Accessibility Nutrition Labels")
        .font(.title)
        .accessibilityAddTraits(.isHeader)
      
      
      // UIKit
      let label = UILabel()
      /*...*/
      label.accessibilityTraits = .header
    • 9:29 - Implement custom adjustable behavior

      // Implement custom adjustable behavior
      
      // SwiftUI
      MySliderView()
        .accessibilityAdjustableAction { direction in
          switch direction {
          case .increment:
            // Increase value
          case .decrement:
            // Decrease value
          }
        }
      
      
      // UIKit
      class MySliderView: UIView {
        override var accessibilityTraits: UIAccessibilityTraits { get { .adjustable } set {} }
        override func accessibilityIncrement() { /* Increase value */ }
        override func accessibilityDecrement() { /* Decrease value */ }
      }
    • 9:54 - Set an accessibility value

      // Set an accessibility value
      
      // SwiftUI
      MyView()
        .accessibilityValue("Value")
      
      
      // UIKit
      myView.accessibilityValue = "Value"
    • 12:26 - Hide decorative images from VoiceOver

      // Hide decorative images from VoiceOver
      
      // SwiftUI
      Image(decorative: landmark.thumbnailImageName)
      /* or */
      Image(landmark.thumbnailImageName)
        .accessibilityHidden(true)
      
      
      // UIKit
      imageView.isAccessibilityElement = false
    • 12:59 - Combine elements to improve VoiceOver navigation

      // Combine elements to improve VoiceOver navigation
      
      HStack {
        HStack {
          Text("SFO")
          Image(systemName: "airplane.departure")
            .accessibilityLabel("to")
          Text("HND")
        }
        .font(.title3.bold())
        Spacer()
        VStack {
          Text("Arriving in")
          Text("15").font(.title.bold())
          Text("minutes")
        }
      }
      .accessibilityElement(children: .combine)
    • 15:03 - Make a custom component accessible

      // Make a custom component accessible
      
      HStack {
        ForEach(1...5, id: \.self) { index in
          Image(systemName: index <= Int(badgeProgress.rating) ? "star.fill" : "star") 
        }
      }
      .accessibilityElement()
      .accessibilityLabel("Rating")
      .accessibilityValue("\(Int(badgeProgress.rating))")
      .accessibilityAdjustableAction { direction in
        switch direction {
        case .increment:
          badgeProgress.rating = min(5, badgeProgress.rating + 1)
        case .decrement:
          badgeProgress.rating = max(0, badgeProgress.rating - 1)
        }
      }
    • 15:37 - Make a custom component accessible

      // Make a custom component accessible
      
      HStack {
        ForEach(1...5, id: \.self) { index in
          Image(systemName: index <= Int(badgeProgress.rating) ? "star.fill" : "star")
        }
      }
      .accessibilityRepresentation {
        Slider(value: $badgeProgress.rating, in: 0...5, step: 1.0) {
          Text("Rating")
        }
      }
    • 16:30 - Add accessibility traits for tap gestures

      // Add accessibility traits for tap gestures
      
      HStack {
        Text("Learn more")
        Image(systemName: "chevron.forward")
      }
      .foregroundColor(.blue)
      .onTapGesture {
        /*...*/
      }
      .accessibilityAddTraits(.isButton)
    • 17:13 - Add accessibility actions for custom gestures

      // Add accessibility actions for custom gestures
      
      Image(landmark.backgroundImageName)
        .accessibilityLabel(landmark.imageDescription ?? landmark.name)
        .onTapGesture(count: 2) {
          modelData.addFavorite(landmark)
        }
        .accessibilityAction(named: "Favorite") {
          modelData.addFavorite(landmark)
        }
    • 20:07 - Adopt system text styles for automatic scaling

      // Adopt system text styles for automatic scaling
      
      // SwiftUI
      Text("Hello World")
        .font(.body)
      
      
      // UIKit
      label.font = UIFont.preferredFont(forTextStyle: .body)
      label.adjustsFontForContentSizeCategory = true
    • 20:33 - Make custom fonts scale proportionally with system font styles

      // Make custom fonts scale proportionally with system font styles
      
      // SwiftUI
      Text("Hello World")
        .font(.custom("MyFont", size: 17, relativeTo: .body))
      
      
      // UIKit
      guard let customFont = UIFont(name: "MyFont", size: 17) else { return }
      label.font = UIFontMetrics(forTextStyle: .body).scaledFont(for: customFont)
      label.adjustsFontForContentSizeCategory = true
    • 22:57 - Embed content in ScrollView to avoid truncation

      // Embed content in ScrollView to avoid truncation
      
      ScrollView {
        VStack(spacing: 24) {
          EarnedBadgeView(badge: badge)
          Text("Congratulations!")
          Text("...")
        }
      }
      .scrollBounceBehavior(.basedOnSize)
      .safeAreaBar(edge: .bottom) {
          VStack {
              Button("Share badge") { }
              Button("Close") { }
          }
      }
    • 25:17 - Set number of lines to 0 to avoid truncation

      // Set number of lines to 0 to avoid truncation
      
      // SwiftUI
      
      Text("Some longer text that takes up multiple lines.")
        .lineLimit(nil)
      
      
      // UIKit
      
      label.numberOfLines = 0
    • 26:53 - Check the differentiate without color setting

      // Check the differentiate without color setting
      
      // SwiftUI
      
      @Environment(\.accessibilityDifferentiateWithoutColor) var differentiateWithoutColor
      
      
      // UIKit
      
      let differentiateWithoutColor = UIAccessibility.shouldDifferentiateWithoutColor
      NotificationCenter.default.addObserver(self, selector: #selector(diffWithoutColorDidChange), name: UIAccessibility.differentiateWithoutColorDidChangeNotification, object: nil)
    • 27:42 - Differentiate without color alone in Swift Charts

      // Differentiate without color alone in Swift Charts
      
      Chart(visitorData) { data in
        LineMark(
          x: .value("Month", data.month),
          y: .value("Visitors", data.numVisitors)
        )
        .foregroundStyle(by: .value("Landmark", data.landmark))
      
        PointMark(
          x: .value("Month", data.month),
          y: .value("Visitors", data.numVisitors)
        )
        .foregroundStyle(by: .value("Landmark", data.landmark))
        .symbol(by: .value("Landmark", data.landmark))
      }
    • 30:36 - Check the preference for Reduce Transparency

      // Check the preference for Reduce Transparency
      
      // SwiftUI
      
      @Environment(\.accessibilityReduceTransparency) var reduceTransparencyEnabled
      
      
      // UIKit
      
      let reduceTransparencyEnabled = UIAccessibility.isReduceTransparencyEnabled
      NotificationCenter.default.addObserver(self, selector: #selector(reduceTransparencyDidChange), name: UIAccessibility.reduceTransparencyStatusDidChangeNotification, object: nil)
    • 31:22 - Check the preference for Increase Contrast

      // Check the preference for Increase Contrast
      
      // SwiftUI
      
      @Environment(\.colorSchemeContrast) var colorSchemeContrast
      
      
      // UIKit
      
      let increaseContrastEnabled = view.traitCollection.accessibilityContrast == .high
      registerForTraitChanges([UITraitAccessibilityContrast.self], action: #selector(accessibilityContrastDidChange))

Developer Footer

  • 视频
  • Tech Talks
  • Prepare your app for Accessibility Nutrition Labels
  • 打开菜单 关闭菜单
    • iOS
    • iPadOS
    • macOS
    • Apple tvOS
    • visionOS
    • watchOS
    打开菜单 关闭菜单
    • Swift
    • SwiftUI
    • Swift Playground
    • TestFlight
    • Xcode
    • Xcode Cloud
    • SF Symbols
    打开菜单 关闭菜单
    • 辅助功能
    • 配件
    • Apple 智能
    • App 扩展
    • App Store
    • 音频与视频 (英文)
    • 增强现实
    • 设计
    • 分发
    • 教育
    • 字体 (英文)
    • 游戏
    • 健康与健身
    • App 内购买项目
    • 本地化
    • 地图与位置
    • 机器学习与 AI
    • 开源资源 (英文)
    • 安全性
    • Safari 浏览器与网页 (英文)
    打开菜单 关闭菜单
    • 完整文档 (英文)
    • 部分主题文档 (简体中文)
    • 教程
    • 下载
    • 论坛 (英文)
    • 视频
    打开菜单 关闭菜单
    • 支持文档
    • 联系我们
    • 错误报告
    • 系统状态 (英文)
    打开菜单 关闭菜单
    • Apple 开发者
    • App Store Connect
    • 证书、标识符和描述文件 (英文)
    • 反馈助理
    打开菜单 关闭菜单
    • 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 Research Device Program (英文)
    打开菜单 关闭菜单
    • 与 Apple 会面交流
    • Apple Developer Center
    • App Store 大奖 (英文)
    • Apple 设计大奖
    • Apple Developer Academies (英文)
    • WWDC
    阅读最近新闻。
    获取 Apple Developer App。
    版权所有 © 2026 Apple Inc. 保留所有权利。
    使用条款 隐私政策 协议和准则