2

How do I check, using UIAccessibility, if the Button Shapes option in the iOS device accessibility settings is enabled? I want to support that 'button style' on a custom made button.

enter image description here

Zandor Smith
  • 558
  • 6
  • 25

1 Answers1

1

I converted the code from this post to Swift:

import UIKit

public extension UIAccessibility {

    public static var isButtonShapesEnabled: Bool {
        let button = UIButton()
        button.setTitle("Button Shapes", for: .normal)
        return button.titleLabel?.attributedText?.attribute(NSAttributedString.Key.underlineStyle, at: 0, effectiveRange: nil) != nil
    }

}

Usage:

if UIAccessibility.isButtonShapesEnabled {
    // Apply button shapes style to custom button...
}
Zandor Smith
  • 558
  • 6
  • 25