Skip to content

Commit 9237958

Browse files
committed
Improve inclusion of additional accessibility elements
1 parent 02a2d5b commit 9237958

File tree

11 files changed

+108
-19
lines changed

11 files changed

+108
-19
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
# Change Log
22
All notable changes to this project will be documented in this file.
33

4+
## [3.3.2](https://github.com/SwiftKickMobile/SwiftMessages/releases/tag/3.3.2)
5+
6+
### Improvements
7+
* `MessageView` is smarter about including additional accessibility views for cases where you've added accessible elements to the view. Previously only the `button` was included. Now all views where `isAccessibilityElement == true`.
8+
9+
Note that all nib files now have `isAccessibilityElement == false` for `titleLabel`, `bodyLabel` and `iconLabel` (`titleLabel` and `bodyLabel` are read out as part of the overall message view's text). If any of these need to be directly accessible, then copy the nib file into your project and select "Enabled" in the Accessibility section of the Identity Inspector.
10+
411
## [3.3.1](https://github.com/SwiftKickMobile/SwiftMessages/releases/tag/3.3.1)
512

613
### Bug Fixes

Demo/Demo.xcodeproj/project.pbxproj

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@
132132
TargetAttributes = {
133133
86AEDCE11D5D1DB70030232E = {
134134
CreatedOnToolsVersion = 7.3.1;
135+
DevelopmentTeam = 38R82CD868;
135136
LastSwiftMigration = 0800;
136137
};
137138
};
@@ -346,7 +347,7 @@
346347
buildSettings = {
347348
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
348349
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
349-
DEVELOPMENT_TEAM = "";
350+
DEVELOPMENT_TEAM = 38R82CD868;
350351
INFOPLIST_FILE = Demo/Info.plist;
351352
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
352353
PRODUCT_BUNDLE_IDENTIFIER = it.swiftkick.Demo;
@@ -361,7 +362,7 @@
361362
buildSettings = {
362363
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
363364
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
364-
DEVELOPMENT_TEAM = "";
365+
DEVELOPMENT_TEAM = 38R82CD868;
365366
INFOPLIST_FILE = Demo/Info.plist;
366367
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
367368
PRODUCT_BUNDLE_IDENTIFIER = it.swiftkick.Demo;

Demo/Demo/TacoDialogView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class TacoDialogView: MessageView {
2424
fileprivate var count = 1 {
2525
didSet {
2626
iconLabel?.text = String(repeating: "🌮", count: count)//String(count: count, repeatedValue: )
27-
titleLabel?.text = TacoDialogView.tacoTitles[count] ?? "\(count)" + String(repeating: "!", count: count)
27+
bodyLabel?.text = TacoDialogView.tacoTitles[count] ?? "\(count)" + String(repeating: "!", count: count)
2828
}
2929
}
3030

Demo/Demo/TacoDialogView.xib

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2-
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="11198.2" systemVersion="15G31" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="11762" systemVersion="16D32" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
3+
<device id="retina4_7" orientation="portrait">
4+
<adaptation id="fullscreen"/>
5+
</device>
36
<dependencies>
47
<deployment identifier="iOS"/>
5-
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11161"/>
8+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11757"/>
69
<capability name="Constraints to layout margins" minToolsVersion="6.0"/>
710
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
811
</dependencies>
@@ -14,16 +17,25 @@
1417
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
1518
<subviews>
1619
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="dp3-Ae-zep" userLabel="Background view">
20+
<rect key="frame" x="18" y="18" width="572" height="281"/>
1721
<subviews>
1822
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" distribution="equalSpacing" spacing="10" translatesAutoresizingMaskIntoConstraints="NO" id="RJH-Fp-YDa" userLabel="Content view">
23+
<rect key="frame" x="30" y="30" width="512" height="221"/>
1924
<subviews>
2025
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" alignment="center" translatesAutoresizingMaskIntoConstraints="NO" id="Irk-mj-bK8">
26+
<rect key="frame" x="0.0" y="0.0" width="512" height="60"/>
2127
<subviews>
2228
<stackView opaque="NO" contentMode="scaleToFill" distribution="fillProportionally" alignment="center" spacing="15" translatesAutoresizingMaskIntoConstraints="NO" id="aav-a1-ogq">
29+
<rect key="frame" x="0.0" y="0.0" width="512" height="60"/>
2330
<subviews>
2431
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="xLT-bX-GJE">
32+
<rect key="frame" x="0.0" y="0.0" width="512" height="60"/>
2533
<subviews>
2634
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="252" verticalHuggingPriority="251" horizontalCompressionResistancePriority="748" text="🌮" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" minimumScaleFactor="0.5" translatesAutoresizingMaskIntoConstraints="NO" id="pFx-Py-lZQ" userLabel="Icon label">
35+
<rect key="frame" x="0.0" y="0.0" width="50" height="60"/>
36+
<accessibility key="accessibilityConfiguration">
37+
<bool key="isElement" value="NO"/>
38+
</accessibility>
2739
<constraints>
2840
<constraint firstAttribute="height" constant="60" id="6yp-AT-q9O"/>
2941
</constraints>
@@ -32,6 +44,10 @@
3244
<nil key="highlightedColor"/>
3345
</label>
3446
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" horizontalCompressionResistancePriority="1000" text="Just one, please." textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="YAk-Zs-x2f">
47+
<rect key="frame" x="65" y="0.0" width="447" height="60"/>
48+
<accessibility key="accessibilityConfiguration">
49+
<bool key="isElement" value="NO"/>
50+
</accessibility>
3551
<fontDescription key="fontDescription" name="Futura-CondensedMedium" family="Futura" pointSize="18"/>
3652
<color key="textColor" red="0.6705882352941176" green="0.51372549019607838" blue="0.13333333333333333" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
3753
<nil key="highlightedColor"/>
@@ -54,17 +70,23 @@
5470
</subviews>
5571
</stackView>
5672
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" verticalCompressionResistancePriority="748" text="How many tocos would you like?" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="gMT-Vh-S3z">
73+
<rect key="frame" x="0.0" y="73.5" width="512" height="23.5"/>
5774
<color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/>
75+
<accessibility key="accessibilityConfiguration">
76+
<bool key="isElement" value="NO"/>
77+
</accessibility>
5878
<fontDescription key="fontDescription" name="Futura-Medium" family="Futura" pointSize="18"/>
5979
<color key="textColor" red="0.40392156862745099" green="0.36862745098039218" blue="0.2627450980392157" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
6080
<nil key="highlightedColor"/>
6181
</label>
6282
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Adjust the taco slider and place your order." textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="U9w-CI-YK7">
83+
<rect key="frame" x="0.0" y="111" width="512" height="17"/>
6384
<fontDescription key="fontDescription" name="Futura-CondensedMedium" family="Futura" pointSize="14"/>
6485
<color key="textColor" red="0.60392156862745094" green="0.44313725490196076" blue="0.10588235294117647" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
6586
<nil key="highlightedColor"/>
6687
</label>
6788
<slider opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" value="1" minValue="1" maxValue="5" translatesAutoresizingMaskIntoConstraints="NO" id="MKs-Kv-aPL">
89+
<rect key="frame" x="-2" y="141.5" width="516" height="31"/>
6890
<color key="minimumTrackTintColor" red="0.94509803921568625" green="0.57647058823529407" blue="0.078431372549019607" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
6991
<connections>
7092
<action selector="tacoSliderFinished:" destination="JI3-gM-XBO" eventType="touchUpInside" id="ekV-4L-MLR"/>
@@ -73,10 +95,13 @@
7395
</connections>
7496
</slider>
7597
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" alignment="bottom" translatesAutoresizingMaskIntoConstraints="NO" id="x8I-RG-nBX">
98+
<rect key="frame" x="0.0" y="185" width="512" height="36"/>
7699
<subviews>
77100
<stackView opaque="NO" contentMode="scaleToFill" spacing="15" translatesAutoresizingMaskIntoConstraints="NO" id="8Qt-TE-nPO">
101+
<rect key="frame" x="355" y="0.0" width="157" height="36"/>
78102
<subviews>
79103
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="yFi-Ik-klX">
104+
<rect key="frame" x="0.0" y="0.0" width="58" height="36"/>
80105
<fontDescription key="fontDescription" type="system" pointSize="15"/>
81106
<state key="normal" title="Forget It">
82107
<color key="titleColor" red="0.94468559679999997" green="0.57750775359999995" blue="0.07530619559" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
@@ -86,6 +111,7 @@
86111
</connections>
87112
</button>
88113
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="rVu-Ei-t6A">
114+
<rect key="frame" x="73" y="0.0" width="84" height="36"/>
89115
<color key="backgroundColor" red="0.94117647058823528" green="0.57647058823529407" blue="0.074509803921568626" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
90116
<fontDescription key="fontDescription" name="Futura-Medium" family="Futura" pointSize="15"/>
91117
<inset key="contentEdgeInsets" minX="8" minY="8" maxX="8" maxY="8"/>
@@ -140,10 +166,10 @@
140166
</userDefinedRuntimeAttributes>
141167
<connections>
142168
<outlet property="backgroundView" destination="dp3-Ae-zep" id="ZiK-GN-SXH"/>
143-
<outlet property="bodyLabel" destination="gMT-Vh-S3z" id="BkZ-P0-0dh"/>
169+
<outlet property="bodyLabel" destination="YAk-Zs-x2f" id="Koz-Jf-jUo"/>
144170
<outlet property="iconLabel" destination="pFx-Py-lZQ" id="xKK-gA-Otu"/>
145171
<outlet property="tacoSlider" destination="MKs-Kv-aPL" id="Iky-UQ-58E"/>
146-
<outlet property="titleLabel" destination="YAk-Zs-x2f" id="ufT-ii-FoC"/>
172+
<outlet property="titleLabel" destination="gMT-Vh-S3z" id="FWK-Tl-hc6"/>
147173
</connections>
148174
<point key="canvasLocation" x="304" y="614.5"/>
149175
</view>

SwiftMessages.podspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
Pod::Spec.new do |spec|
22
spec.name = 'SwiftMessages'
3-
spec.version = '3.3.1'
3+
spec.version = '3.3.2'
44
spec.license = { :type => 'MIT' }
55
spec.homepage = 'https://github.com/SwiftKickMobile/SwiftMessages'
66
spec.authors = { 'Timothy Moose' => 'tim@swiftkick.it' }
77
spec.summary = 'A very flexible message bar for iOS written in Swift.'
8-
spec.source = {:git => 'https://github.com/SwiftKickMobile/SwiftMessages.git', :tag => '3.3.1'}
8+
spec.source = {:git => 'https://github.com/SwiftKickMobile/SwiftMessages.git', :tag => '3.3.2'}
99
spec.platform = :ios, '8.0'
1010
spec.ios.deployment_target = '8.0'
1111
spec.source_files = 'SwiftMessages/**/*.swift'

SwiftMessages/MessageView.swift

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,20 @@ open class MessageView: BaseView, Identifiable, AccessibleMessage {
105105
}
106106

107107
open var additonalAccessibilityElements: [NSObject]? {
108-
if let button = button { return [button] }
109-
return nil
108+
var elements: [NSObject] = []
109+
func getAccessibleSubviews(view: UIView) {
110+
for subview in view.subviews {
111+
if subview.isAccessibilityElement {
112+
elements.append(subview)
113+
} else {
114+
// Only doing this for non-accessible `subviews`, which avoids
115+
// including button labels, etc.
116+
getAccessibleSubviews(view: subview)
117+
}
118+
}
119+
}
120+
getAccessibleSubviews(view: self.backgroundView)
121+
return elements
110122
}
111123
}
112124

SwiftMessages/Resources/CardView.xib

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="11762" systemVersion="16C67" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="11762" systemVersion="16D32" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
33
<device id="retina4_7" orientation="portrait">
44
<adaptation id="fullscreen"/>
55
</device>
@@ -24,6 +24,9 @@
2424
<subviews>
2525
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="252" verticalHuggingPriority="251" horizontalCompressionResistancePriority="752" text="😬" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="pFx-Py-lZQ" userLabel="Icon label">
2626
<rect key="frame" x="0.0" y="24" width="43" height="45.5"/>
27+
<accessibility key="accessibilityConfiguration">
28+
<bool key="isElement" value="NO"/>
29+
</accessibility>
2730
<fontDescription key="fontDescription" type="system" pointSize="38"/>
2831
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
2932
<nil key="highlightedColor"/>
@@ -36,13 +39,19 @@
3639
<subviews>
3740
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" verticalCompressionResistancePriority="751" text="[Title]" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="IWB-BS-FgD">
3841
<rect key="frame" x="0.0" y="0.0" width="48" height="20.5"/>
42+
<accessibility key="accessibilityConfiguration">
43+
<bool key="isElement" value="NO"/>
44+
</accessibility>
3945
<fontDescription key="fontDescription" style="UICTFontTextStyleHeadline"/>
4046
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
4147
<nil key="highlightedColor"/>
4248
</label>
4349
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="[Message Body]" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="gMT-Vh-S3z">
4450
<rect key="frame" x="0.0" y="20.5" width="111.5" height="18"/>
4551
<color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/>
52+
<accessibility key="accessibilityConfiguration">
53+
<bool key="isElement" value="NO"/>
54+
</accessibility>
4655
<fontDescription key="fontDescription" style="UICTFontTextStyleSubhead"/>
4756
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
4857
<nil key="highlightedColor"/>

0 commit comments

Comments
 (0)