From 0178f9a4ea08155c5d559feb719c74f6d1fce2da Mon Sep 17 00:00:00 2001 From: EugeneKlyuenkov Date: Tue, 24 Jan 2023 15:22:42 +0300 Subject: [PATCH 1/2] II-16-[added accessibility] --- Source/PlaceholderTextView.swift | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Source/PlaceholderTextView.swift b/Source/PlaceholderTextView.swift index 2430aba..13ffe4f 100644 --- a/Source/PlaceholderTextView.swift +++ b/Source/PlaceholderTextView.swift @@ -55,6 +55,7 @@ public class PlaceholderTextView: UITextView { placeholderTextView.text = newValue invalidateIntrinsicContentSize() updatePlaceholder() + setupAccessibility() } } @@ -66,6 +67,7 @@ public class PlaceholderTextView: UITextView { placeholderTextView.attributedText = newValue invalidateIntrinsicContentSize() updatePlaceholder() + setupAccessibility() } } @@ -83,12 +85,14 @@ public class PlaceholderTextView: UITextView { override public var text: String! { didSet { updatePlaceholder() + setupAccessibility() } } override public var attributedText: NSAttributedString! { didSet { updatePlaceholder() + setupAccessibility() } } @@ -207,6 +211,17 @@ public class PlaceholderTextView: UITextView { return placeholder }() + private func setupAccessibility() { + placeholderTextView.isAccessibilityElement = false + placeholderTextView.accessibilityElementsHidden = true + if placeholderTextView.alpha > 0 && placeholderTextView.superview != nil, + let text = placeholderTextView.text, !text.isEmpty { + accessibilityLabel = text + } else { + accessibilityLabel = nil + } + } + } private extension PlaceholderTextView { @@ -227,6 +242,7 @@ private extension PlaceholderTextView { }) } updatePlaceholder() + setupAccessibility() updateTextWithLimit() textDidChange?(text) } From 29abaaa5d8026d100e2aab5704652269e949e435 Mon Sep 17 00:00:00 2001 From: EugeneKlyuenkov Date: Tue, 24 Jan 2023 15:23:26 +0300 Subject: [PATCH 2/2] II-16-[updated pod spec] --- Shakuro.PlaceholderTextView.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Shakuro.PlaceholderTextView.podspec b/Shakuro.PlaceholderTextView.podspec index 23ff50b..9256a6d 100644 --- a/Shakuro.PlaceholderTextView.podspec +++ b/Shakuro.PlaceholderTextView.podspec @@ -1,7 +1,7 @@ Pod::Spec.new do |s| s.name = 'Shakuro.PlaceholderTextView' - s.version = '1.0.0' + s.version = '1.0.1' s.summary = 'PlaceholderTextView' s.homepage = 'https://github.com/shakurocom/PlaceholderTextView' s.license = { :type => "MIT", :file => "LICENSE.md" }