AccessibilityKit is a collection of APIs to help you develop more visually accessible apps, for the times when iOS doesn't have you covered.
AKTextView
is a text view that automatically and efficiently draws text using the largest possible font size, spanning multiple lines as needed to fill the view's bounds. It's great for when you need some text or label to be as visually accessible as possible, or to just generally make it more appealing. It's efficient enough that it can perform real-time resizing, if you ever need to do that.
As a bonus, you can also use all attributes of NSAttributedString
, as well as a built-in vertical alignment option. And emoji, of course.
UILabel
'sadjustsFontSizeToFitWidth
doesn't support multiple lines.UITextView
andNSTextView
don't haveadjustsFontSizeToFitWidth
.- Other solutions might render text incorrectly.
- Other solutions don't support attributed strings.
- Other solutions are slow.
- 😠😤😩
You can use AKTextView
as a drop-in replacement for UITextView
and NSTextView
(iOS and macOS). There's also AKLabel
(replacement for UILabel
), as well as AKView
, an even more performant and bare-bones subclass of UIView
.
iOS:
let view = AKTextView()
// Use a simple or fancy NSAttributedString.
view.attributedText = .init(string: "Some text here", attributes: [
.font: UIFont.systemFont(ofSize: 12), // Font size will be ignored
.foregroundColor: UIColor.black,
])
// Add to the view hierarchy...
macOS:
let view = AKTextView()
view.string = "Some text here"
// Add to the view hierarchy...
AccessibilityKit is used in the award-winning, low-vision keyboard FlickType.