搜索

PythonReactSEOPDF
GitHub Skill

ios-accessibility-skill

Best practices for implementing accessibility features in iOS apps, including VoiceOver support, Dynamic Type, and Human Interface Guidelines compliance.

pstuart☆ 20 仓库 Stars5 仓库 Forks

安装与使用

请根据来源仓库和你的 AI 工具说明安装此技能。先阅读技能文件和依赖要求,再添加到工作流。

查看来源 ↗使用指南

技能说明

iOS Accessibility Skill

This skill focuses on making iOS applications accessible to all users, including those with visual, motor, or cognitive impairments. It covers VoiceOver, Dynamic Type, and adherence to Apple's Human Interface Guidelines (HIG) for accessibility.

Best Practices

  1. VoiceOver Support: Ensure all UI elements are properly labeled and navigable with VoiceOver.

  2. Dynamic Type: Support text scaling for users with visual impairments.

  3. Color and Contrast: Use sufficient color contrast and don't rely solely on color to convey information.

  4. Touch Targets: Make interactive elements large enough (44x44 points minimum).

  5. HIG Compliance: Follow Apple's accessibility guidelines throughout the design and development process.

  6. Testing: Regularly test with accessibility features enabled.

Accessibility Guidelines

  • Use semantic UI elements that come with built-in accessibility support.
  • Provide meaningful labels and hints for custom controls.
  • Group related elements and provide headers for complex layouts.
  • Support assistive technologies like VoiceOver, Zoom, and Switch Control.
  • Consider motor impairments when designing interactions.
  • Test with real users when possible.

Examples

Example 1: VoiceOver Labels in SwiftUI

User Prompt: "How do I add VoiceOver labels to SwiftUI buttons?"

Expected Output:

import SwiftUI

struct AccessibleButtonView: View {
    var body: some View {
        VStack {
            Button(action: {
                // Action
            }) {
                Image(systemName: "star.fill")
                    .font(.largeTitle)
            }
            .accessibilityLabel("Favorite this item")
            .accessibilityHint("Double tap to add to favorites")
            
            Button("Submit", action: {
                // Submit action
            })
            .accessibilityHint("This will send your information")
        }
    }
}
Example 2: Dynamic Type Support

User Prompt: "Implement Dynamic Type in a SwiftUI text view."

Expected Output:

import SwiftUI

struct DynamicTextView: View {
    var body: some View {
        VStack {
            Text("This text scales with Dynamic Type")
                .font(.body)
            
            Text("Headline that adapts")
                .font(.headline)
            
            Text("Custom font that scales")
                .font(.system(size: 17, weight: .regular, design: .default))
                .minimumScaleFactor(0.8)
                .lineLimit(1)
        }
        .padding()
    }
}
Example 3: Accessible Form in UIKit

User Prompt: "Create an accessible login form in UIKit with VoiceOver support."

Expected Output:

import UIKit

class LoginViewController: UIViewController {
    let emailTextField = UITextField()
    let passwordTextField = UITextField()
    let loginButton = UIButton(type: .system)
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        // Email field
        emailTextField.placeholder = "Email"
        emailTextField.keyboardType = .emailAddress
        emailTextField.accessibilityLabel = "Email address"
        emailTextField.accessibilityHint = "Enter your email address"
        
        // Password field
        passwordTextField.placeholder = "Password"
        passwordTextField.isSecureTextEntry = true
        passwordTextField.accessibilityLabel = "Password"
        passwordTextField.accessibilityHint = "Enter your password"
        
        // Login button
        loginButton.setTitle("Log In", for: .normal)
        loginButton.accessibilityHint = "Tap to log in to your account"
        
        // Layout code here...
    }
}
Example 4: Grouping Elements

User Prompt: "How to group related accessibility elements in SwiftUI?"

Expected Output:

import SwiftUI

struct GroupedElementsView: View {
    var body: some View {
        VStack {
            VStack {
                Text("Contact Information")
                    .font(.headline)
                TextField("Name", text: .constant(""))
                TextField("Phone", text: .constant(""))
            }
            .accessibilityElement(children: .combine)
            .accessibilityLabel("Contact information form")
            
            Button("Save Contact") {
                // Save action
            }
            .accessibilityHint("Saves the contact information")
        }
        .padding()
    }
}
Example 5: Color Contrast and Alternative Text

User Prompt: "Ensure good color contrast and provide alternatives for color-dependent information."

Expected Output:

import SwiftUI

struct ColorAccessibleView: View {
    @State private var isSelected = false
    
    var body: some View {
        VStack {
            // Good contrast example
            Text("Important Message")
                .foregroundColor(.white)
                .background(Color.black)
                .padding()
            
            // Color + shape indicator
            HStack {
                Circle()
                    .fill(isSelected ? Color.green : Color.red)
                    .frame(width: 20, height: 20)
                Text(isSelected ? "Online" : "Offline")
            }
            .accessibilityElement(children: .combine)
            .accessibilityLabel(isSelected ? "Status: Online" : "Status: Offline")
            
            Button(action: { isSelected.toggle() }) {
                Text("Toggle Status")
            }
            .accessibilityHint("Changes the online status indicator")
        }
    }
}

使用示例

查看来源仓库中的使用示例与配置说明。

查看来源 ↗

来源历史

收录时间
2026-01-20
索引更新时间
2026-02-02
Branch
main

收录与同步日期属于本站记录。源码修改历史请查看来源仓库。

GitHub ↗

chat Comments (0)

chat_bubble_outline

No comments yet. Be the first to share your thoughts!