Skip to content

Commit 1f17508

Browse files
committed
Add Accessibility feature to Bar Items Images in the tab bar
1 parent d88fada commit 1f17508

File tree

9 files changed

+58
-24
lines changed

9 files changed

+58
-24
lines changed

SaVaGe/SaVaGe/AccessibilityViewController.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,16 @@ import UIKit
1111
class AccessibilityViewController: UIViewController {
1212
@IBOutlet weak var pumpkinPngImageView: UIImageView!
1313
@IBOutlet weak var pumpkinPdfImageView: UIImageView!
14+
@IBOutlet weak var accessibilityBarItem: UITabBarItem!
1415

1516
override func viewDidLoad() {
1617
super.viewDidLoad()
1718

1819
if #available(iOS 11.0, *) {
1920
pumpkinPngImageView.adjustsImageSizeForAccessibilityContentSizeCategory = true
2021
pumpkinPdfImageView.adjustsImageSizeForAccessibilityContentSizeCategory = true
22+
let image = UIImage(named: "second_large")
23+
accessibilityBarItem.largeContentSizeImage = image
2124
} else {
2225
// Fallback on earlier versions
2326
}

SaVaGe/SaVaGe/Assets.xcassets/first.imageset/Contents.json

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,14 @@
22
"images" : [
33
{
44
"idiom" : "universal",
5-
"filename" : "tabbar_images.pdf",
6-
"scale" : "1x"
7-
},
8-
{
9-
"idiom" : "universal",
10-
"scale" : "2x"
11-
},
12-
{
13-
"idiom" : "universal",
14-
"scale" : "3x"
5+
"filename" : "tabbar_images.pdf"
156
}
167
],
178
"info" : {
189
"version" : 1,
1910
"author" : "xcode"
11+
},
12+
"properties" : {
13+
"preserves-vector-representation" : true
2014
}
2115
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"images" : [
3+
{
4+
"idiom" : "universal",
5+
"filename" : "first_large.pdf"
6+
}
7+
],
8+
"info" : {
9+
"version" : 1,
10+
"author" : "xcode"
11+
},
12+
"properties" : {
13+
"preserves-vector-representation" : true
14+
}
15+
}
Binary file not shown.

SaVaGe/SaVaGe/Assets.xcassets/second.imageset/Contents.json

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,14 @@
22
"images" : [
33
{
44
"idiom" : "universal",
5-
"filename" : "tabbar_buttons.pdf",
6-
"scale" : "1x"
7-
},
8-
{
9-
"idiom" : "universal",
10-
"scale" : "2x"
11-
},
12-
{
13-
"idiom" : "universal",
14-
"scale" : "3x"
5+
"filename" : "tabbar_buttons.pdf"
156
}
167
],
178
"info" : {
189
"version" : 1,
1910
"author" : "xcode"
11+
},
12+
"properties" : {
13+
"preserves-vector-representation" : true
2014
}
2115
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"images" : [
3+
{
4+
"idiom" : "universal",
5+
"filename" : "second_large.pdf"
6+
}
7+
],
8+
"info" : {
9+
"version" : 1,
10+
"author" : "xcode"
11+
},
12+
"properties" : {
13+
"preserves-vector-representation" : true
14+
}
15+
}
Binary file not shown.

SaVaGe/SaVaGe/Base.lproj/Main.storyboard

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,10 @@
114114
</constraints>
115115
<viewLayoutGuide key="safeArea" id="PQr-Ze-W5v"/>
116116
</view>
117-
<tabBarItem key="tabBarItem" title="Images" image="first" largeContentSizeImage="first" id="acW-dT-cKf"/>
117+
<tabBarItem key="tabBarItem" title="Images" image="first" largeContentSizeImage="first_large" id="acW-dT-cKf"/>
118+
<connections>
119+
<outlet property="imagesBarItem" destination="acW-dT-cKf" id="o5g-aT-Lfo"/>
120+
</connections>
118121
</viewController>
119122
<placeholder placeholderIdentifier="IBFirstResponder" id="W5J-7L-Pyd" sceneMemberID="firstResponder"/>
120123
</objects>
@@ -172,8 +175,9 @@
172175
</constraints>
173176
<viewLayoutGuide key="safeArea" id="O1u-W8-tvY"/>
174177
</view>
175-
<tabBarItem key="tabBarItem" title="Accessibility" image="second" id="cPa-gy-q4n"/>
178+
<tabBarItem key="tabBarItem" title="Accessibility" image="second" largeContentSizeImage="second_large" id="cPa-gy-q4n"/>
176179
<connections>
180+
<outlet property="accessibilityBarItem" destination="cPa-gy-q4n" id="5ov-n1-4Sv"/>
177181
<outlet property="pumpkinPdfImageView" destination="QuR-CM-wkQ" id="eFt-Tx-4zq"/>
178182
<outlet property="pumpkinPngImageView" destination="1DA-4C-9fI" id="DFp-k6-ncn"/>
179183
</connections>
@@ -205,8 +209,10 @@
205209
<image name="cat_pdf" width="96" height="94"/>
206210
<image name="cat_png" width="96" height="94"/>
207211
<image name="first" width="24" height="30"/>
212+
<image name="first_large" width="55" height="72"/>
208213
<image name="pumpkin_pdf" width="96" height="94"/>
209214
<image name="pumpkin_png" width="96" height="94"/>
210215
<image name="second" width="30" height="30"/>
216+
<image name="second_large" width="75" height="75"/>
211217
</resources>
212218
</document>

SaVaGe/SaVaGe/ImagesViewController.swift

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,17 @@
99
import UIKit
1010

1111
class ImagesViewController: UIViewController {
12-
12+
@IBOutlet weak var imagesBarItem: UITabBarItem!
13+
1314
override func viewDidLoad() {
1415
super.viewDidLoad()
15-
// Do any additional setup after loading the view, typically from a nib.
16+
17+
if #available(iOS 11.0, *) {
18+
let image = UIImage(named: "first_large")
19+
imagesBarItem.largeContentSizeImage = image
20+
} else {
21+
// Fallback on earlier versions
22+
}
1623
}
1724

1825
override func didReceiveMemoryWarning() {

0 commit comments

Comments
 (0)