To help ensure your buttons are accessible to as many users as possible, please be sure to review the following recommendations:
Set an appropriate
accessibilityLabel
value if your button does not have a title. This is often the case with Floating
Action Button instances which typically only have an icon.
button.accessibilityLabel = @"Create";
button.accessibilityLabel = "Create"
Make sure that your buttons have a minimum touch area. The Material spec for buttons calls for buttons that have a visual height of 36 and that touch areas should be at least 48 points high and 48 wide.
To keep a button's visual sizes small with larger touchable areas, set the
hitAreaInsets
to a negative value. Be careful to maintain sufficient distance
between the button touch targets. This will allow your button to have a large
enough touch
target
while maintaining the desired visual appearance. For more see the Touch and click
targets
in the spec.
CGFloat verticalInset = MIN(0, -(48 - CGRectGetHeight(button.bounds)) / 2);
CGFloat horizontalInset = MIN(0, -(48 - CGRectGetWidth(button.bounds)) / 2);
button.hitAreaInsets = UIEdgeInsetsMake(verticalInset, horizontalInset, verticalInset, horizontalInset);
let buttonVerticalInset =
min(0, -(kMinimumAccessibleButtonSize.height - button.bounds.height) / 2);
let buttonHorizontalInset =
min(0, -(kMinimumAccessibleButtonSize.width - button.bounds.width) / 2);
button.hitAreaInsets =
UIEdgeInsetsMake(buttonVerticalInset, buttonHorizontalInset,
buttonVerticalInset, buttonHorizontalInset);
Set your buttons to have a minimum size. Material Buttons guidelines typically recommend a minimum height of 36 points and a minimum width of 64 points.
button.minimumSize = CGSizeMake(64, 36);
button.minimumSize = CGSize(width: 64, height: 48)
However there are some clear exceptions for these rules. Please adjust your buttons sizes accordingly.
Apple rarely recommends using the accessibilityHint
because the label should
already be clear enough to indicate what will happen. Before you consider
setting an -accessibilityHint
consider if you need it or if the rest of your
UI could be adjusted to make it more contextually clear.
A well-crafted, thoughtful user interface can remove the need for
accessibilityHint
in most situations. Examples for a selection dialog to
choose one or more days of the week for a repeating calendar event:
- (Good) The dialog includes a header above the list of days reading, "Event
repeats weekly on the following day(s)." The list items do not need
accessibilityHint
values. - (Bad) The dialog has no header above the list of days. Each list item
(representing a day of the week) has the
accessibilityHint
value, "Toggles this day."