In ScrollView
Identifies text elements and ensures that an ancestor of the element is within a scroll view.
Impact
People utilizing Dynamic Type on iOS are most impacted. When Dynamic Type is on, text sizes can be increased and may move off-screen. If the text is not within a scroll view, the information will not be available to the end-user. Scroll views are a great way to support various screen sizes, ensuring all content is accessible.
Confirmation
- If the content on the page takes up less than one screen, make all text larger with Dynamic Type:
- If using a simulator:
- Open Accessibility Inspector
- On the top-left corner of the inspector, change the device from your Mac to the iOS simulator
- Select the "Settings" button in the top-right corner of the inspector
- Under "Font Size", move the slider to a larger setting
- If using an iOS 13.0+ device:
- Open up Settings
- Select "Accessibility"
- Select "Display & Text Size"
- Select "Larger Text"
- Move the slider at the bottom of the page to a larger setting
- If using a simulator:
- Attempt to scroll to the text element
- Inaccessible: You were unable to scroll to the text element.
- Accessible: You were able to scroll to the text element.
How to Fix
An issue found by this rule is caused by not using a UIScrollView or ScrollView in your application for text elements.
Note: If text is a part of a pinned element, such as UINavigationBar, UITabBar, etc, UILargeContentViewer should be used instead.
UIKit
Add a UIScrollView as the parent view of your screen's elements. This tutorial from Ray Wenderlich offers a great guide.
SwiftUI
Adding text within a ScrollView:
var body: some View {
ScrollView {
VStack {
HStack {
Text("This text is in a scroll view")
.padding()
}
}
}
}