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

0

1 Answer 1

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...
}

Not the answer you're looking for? Browse other questions tagged or ask your own question.