Saltar al contenido principal
Versión: 0.79

AccessibilityInfo

Traducción Beta No Oficial

Esta página fue traducida por PageTurner AI (beta). No está respaldada oficialmente por el proyecto. ¿Encontraste un error? Reportar problema →

A veces es útil saber si el dispositivo tiene un lector de pantalla activo actualmente. La API AccessibilityInfo está diseñada para este propósito. Puedes usarla para consultar el estado actual del lector de pantalla y también para registrarte y recibir notificaciones cuando cambie su estado.

Ejemplo


Referencia

Métodos

addEventListener()

tsx
static addEventListener(
eventName: AccessibilityChangeEventName | AccessibilityAnnouncementEventName,
handler: (
event: AccessibilityChangeEvent | AccessibilityAnnouncementFinishedEvent,
) => void,
): EmitterSubscription;

Añade un controlador de eventos. Eventos compatibles:

Event nameDescription
accessibilityServiceChanged
Android
Fires when some services such as TalkBack, other Android assistive technologies, and third-party accessibility services are enabled. The argument to the event handler is a boolean. The boolean is true when a some accessibility services is enabled and false otherwise.
announcementFinished
iOS
Fires when the screen reader has finished making an announcement. The argument to the event handler is a dictionary with these keys:
  • announcement: The string announced by the screen reader.
  • success: A boolean indicating whether the announcement was successfully made.
boldTextChanged
iOS
Fires when the state of the bold text toggle changes. The argument to the event handler is a boolean. The boolean is true when bold text is enabled and false otherwise.
grayscaleChanged
iOS
Fires when the state of the gray scale toggle changes. The argument to the event handler is a boolean. The boolean is true when a gray scale is enabled and false otherwise.
invertColorsChanged
iOS
Fires when the state of the invert colors toggle changes. The argument to the event handler is a boolean. The boolean is true when invert colors is enabled and false otherwise.
reduceMotionChangedFires when the state of the reduce motion toggle changes. The argument to the event handler is a boolean. The boolean is true when a reduce motion is enabled (or when "Transition Animation Scale" in "Developer options" is "Animation off") and false otherwise.
reduceTransparencyChanged
iOS
Fires when the state of the reduce transparency toggle changes. The argument to the event handler is a boolean. The boolean is true when reduce transparency is enabled and false otherwise.
screenReaderChangedFires when the state of the screen reader changes. The argument to the event handler is a boolean. The boolean is true when a screen reader is enabled and false otherwise.

announceForAccessibility()

tsx
static announceForAccessibility(announcement: string);

Publica una cadena para que sea anunciada por el lector de pantalla.


announceForAccessibilityWithOptions()

tsx
static announceForAccessibilityWithOptions(
announcement: string,
options: {queue?: boolean},
);

Publica una cadena para que sea anunciada por el lector de pantalla con opciones de modificación. Por defecto, los anuncios interrumpirán cualquier voz existente, pero en iOS se pueden encolar detrás del habla existente estableciendo queue como true en el objeto de opciones.

Parámetros:

NameTypeDescription
announcement
Required
stringThe string to be announced
options
Required
objectqueue - queue the announcement behind existing speech
iOS

getRecommendedTimeoutMillis()
Android

tsx
static getRecommendedTimeoutMillis(originalTimeout: number): Promise<number>;

Obtiene el tiempo de espera en milisegundos que necesita el usuario. Este valor se establece en "Tiempo para realizar acciones (Tiempo de espera de accesibilidad)" dentro de la configuración de "Accesibilidad".

Parámetros:

NameTypeDescription
originalTimeout
Required
numberThe timeout to return if "Accessibility timeout" is not set. Specify in milliseconds.

isAccessibilityServiceEnabled()
Android

tsx
static isAccessibilityServiceEnabled(): Promise<boolean>;

Verifica si algún servicio de accesibilidad está habilitado. Esto incluye TalkBack y cualquier aplicación de accesibilidad de terceros que pueda estar instalada. Para verificar únicamente si TalkBack está habilitado, usa isScreenReaderEnabled. Devuelve una promesa que se resuelve en un booleano. El resultado es true cuando algún servicio de accesibilidad está habilitado y false en caso contrario.

Nota: Por favor, usa isScreenReaderEnabled si solo quieres verificar el estado de TalkBack.


isBoldTextEnabled()
iOS

tsx
static isBoldTextEnabled(): Promise<boolean>:

Consulta si el texto en negrita está actualmente habilitado. Devuelve una promesa que se resuelve en un booleano. El resultado es true cuando el texto en negrita está habilitado y false en caso contrario.


isGrayscaleEnabled()
iOS

tsx
static isGrayscaleEnabled(): Promise<boolean>;

Consulta si la escala de grises está actualmente habilitada. Devuelve una promesa que se resuelve en un booleano. El resultado es true cuando la escala de grises está habilitada y false en caso contrario.


isInvertColorsEnabled()
iOS

tsx
static isInvertColorsEnabled(): Promise<boolean>;

Consulta si la inversión de colores está actualmente habilitada. Devuelve una promesa que se resuelve en un booleano. El resultado es true cuando la inversión de colores está habilitada y false en caso contrario.


isReduceMotionEnabled()

tsx
static isReduceMotionEnabled(): Promise<boolean>;

Consulta si la reducción de movimiento está actualmente habilitada. Devuelve una promesa que se resuelve en un booleano. El resultado es true cuando la reducción de movimiento está habilitada y false en caso contrario.


isReduceTransparencyEnabled()
iOS

tsx
static isReduceTransparencyEnabled(): Promise<boolean>;

Consulta si la reducción de transparencia está actualmente habilitada. Devuelve una promesa que se resuelve en un booleano. El resultado es true cuando la reducción de transparencia está habilitada y false en caso contrario.


isScreenReaderEnabled()

tsx
static isScreenReaderEnabled(): Promise<boolean>;

Consulta si un lector de pantalla está actualmente habilitado. Devuelve una promesa que se resuelve en un booleano. El resultado es true cuando un lector de pantalla está habilitado y false en caso contrario.


prefersCrossFadeTransitions()
iOS

tsx
static prefersCrossFadeTransitions(): Promise<boolean>;

Consulta si la reducción de movimiento y la preferencia por transiciones de fundido cruzado están actualmente habilitadas. Devuelve una promesa que se resuelve en un booleano. El resultado es true cuando se prefiere el fundido cruzado en transiciones y false en caso contrario.


setAccessibilityFocus()

Obsoleto

Se recomienda usar sendAccessibilityEvent con eventType focus en su lugar.

tsx
static setAccessibilityFocus(reactTag: number);

Establece el foco de accesibilidad en un componente de React.

En Android, esto llama al método UIManager.sendAccessibilityEvent con los argumentos reactTag y UIManager.AccessibilityEventTypes.typeViewFocused.

nota

Asegúrate de que cualquier View que quieras que reciba el foco de accesibilidad tenga accessible={true}.


sendAccessibilityEvent()

tsx
static sendAccessibilityEvent(host: HostInstance, eventType: AccessibilityEventTypes);

Activa imperativamente un evento de accesibilidad en un componente de React, como cambiar el elemento enfocado para un lector de pantalla.

nota

Asegúrate de que cualquier View que quieras que reciba el foco de accesibilidad tenga accessible={true}.

NameTypeDescription
host
Required
HostInstanceThe component ref to send the event to.
eventType
Required
AccessibilityEventTypesOne of 'click' (Android only), 'focus', 'viewHoverEnter' (Android only), or 'windowStateChange' (Android only)