---
title: Day 83
author: Daniel Devesa Derksen-Staats
date: 2022-08-09 15:31
tags: UISwitch, accessibilityLabel, iOS
categories: ["Accessibility"]
series: ["365 Days iOS Accessibility"]
image: /Images/365DaysIOSAccessibility/image127.jpg
---

Very often we need to show a UISwitch preceded with a UILabel that explains what it does. The text in the label is basically the accessibility label for the switch. Ideally we want for both components to be grouped behave as a UISwitch.

![There is a semi-modal screen from the Twitter app asking for mic permissions. It shows two libels, a title that says "Allow mic access" and a description that says: "Let Twitter access your device's mic" and followed by a switch button. Ideally, all these three elements are a single accessibility element and VocieOver would announce it as: "Allow mic access. Let Twitter access your device's mic. Switch button, off, Double-tap to toggle setting". If the user double-taps it, VoiceOver will announce the change of value and just say: "on". To do that you can enclose these elements into a container view and override isAccessibilityElement to return true, and accessibilityLabel, to return the concatenation of title and description, accessibilityValue, accessibilityTraits and accessibilityHint to proxy the UISwitch values. And finally override accessibilityActivate to toggle the value for the UISwitch.](/Images/365DaysIOSAccessibility/image127.jpg)

It makes much easier to understand what the switch does, compared to having two separate accessible components. There is a number of ways you can do that. One of them is to use a container view and proxy the switch accessibility attributes.

