---
title: Day 110
author: Daniel Devesa Derksen-Staats
date: 2022-09-05 10:39
tags: SwiftUI, UIKit
categories: ["Accessibility"]
series: ["365 Days iOS Accessibility"]
image: /Images/365DaysIOSAccessibility/image102.jpg
---

As with UIKit, in SwiftUI you can also add/remove a11y traits. But because of its declarative nature, you'll have to approach it in a slightly different way. A little nuance, but something that made me scratch my UIKit head when learning SwitUI.

![Two upsell  to premium buttons. One of them says "Monthly, $2.99 per month, billed monthly". The other one is the same but has the colours inverted and a check icon inside a circle, indicating that the option is selected. In UIKit, you would probably initialise the component with the button trait and somewhere else in the code, you'd check if it is selected and insert the selected trait, or remove it otherwise. With SwitUI, on the other hand, you'd probably use the accessibilityAddTraits modifier and use a ternary condition, if it is selected, you add both the isSelected and isButton traits, if not, just the isButton.](/Images/365DaysIOSAccessibility/image102.jpg)