Permalink
Browse files

Add Accessibility feature to Bar Items Images in the tab bar

  • Loading branch information...
jgonfer committed Nov 4, 2017
1 parent d88fada commit 1f1750806162dedc0bea784a6e17c53572ea79d7
@@ -11,13 +11,16 @@ import UIKit
class AccessibilityViewController: UIViewController {
@IBOutlet weak var pumpkinPngImageView: UIImageView!
@IBOutlet weak var pumpkinPdfImageView: UIImageView!
@IBOutlet weak var accessibilityBarItem: UITabBarItem!

override func viewDidLoad() {
super.viewDidLoad()

if #available(iOS 11.0, *) {
pumpkinPngImageView.adjustsImageSizeForAccessibilityContentSizeCategory = true
pumpkinPdfImageView.adjustsImageSizeForAccessibilityContentSizeCategory = true
let image = UIImage(named: "second_large")
accessibilityBarItem.largeContentSizeImage = image
} else {
// Fallback on earlier versions
}
@@ -2,20 +2,14 @@
"images" : [
{
"idiom" : "universal",
"filename" : "tabbar_images.pdf",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
"filename" : "tabbar_images.pdf"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
},
"properties" : {
"preserves-vector-representation" : true
}
}
@@ -0,0 +1,15 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "first_large.pdf"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
},
"properties" : {
"preserves-vector-representation" : true
}
}
@@ -2,20 +2,14 @@
"images" : [
{
"idiom" : "universal",
"filename" : "tabbar_buttons.pdf",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
"filename" : "tabbar_buttons.pdf"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
},
"properties" : {
"preserves-vector-representation" : true
}
}
@@ -0,0 +1,15 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "second_large.pdf"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
},
"properties" : {
"preserves-vector-representation" : true
}
}
@@ -114,7 +114,10 @@
</constraints>
<viewLayoutGuide key="safeArea" id="PQr-Ze-W5v"/>
</view>
<tabBarItem key="tabBarItem" title="Images" image="first" largeContentSizeImage="first" id="acW-dT-cKf"/>
<tabBarItem key="tabBarItem" title="Images" image="first" largeContentSizeImage="first_large" id="acW-dT-cKf"/>
<connections>
<outlet property="imagesBarItem" destination="acW-dT-cKf" id="o5g-aT-Lfo"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="W5J-7L-Pyd" sceneMemberID="firstResponder"/>
</objects>
@@ -172,8 +175,9 @@
</constraints>
<viewLayoutGuide key="safeArea" id="O1u-W8-tvY"/>
</view>
<tabBarItem key="tabBarItem" title="Accessibility" image="second" id="cPa-gy-q4n"/>
<tabBarItem key="tabBarItem" title="Accessibility" image="second" largeContentSizeImage="second_large" id="cPa-gy-q4n"/>
<connections>
<outlet property="accessibilityBarItem" destination="cPa-gy-q4n" id="5ov-n1-4Sv"/>
<outlet property="pumpkinPdfImageView" destination="QuR-CM-wkQ" id="eFt-Tx-4zq"/>
<outlet property="pumpkinPngImageView" destination="1DA-4C-9fI" id="DFp-k6-ncn"/>
</connections>
@@ -205,8 +209,10 @@
<image name="cat_pdf" width="96" height="94"/>
<image name="cat_png" width="96" height="94"/>
<image name="first" width="24" height="30"/>
<image name="first_large" width="55" height="72"/>
<image name="pumpkin_pdf" width="96" height="94"/>
<image name="pumpkin_png" width="96" height="94"/>
<image name="second" width="30" height="30"/>
<image name="second_large" width="75" height="75"/>
</resources>
</document>
@@ -9,10 +9,17 @@
import UIKit

class ImagesViewController: UIViewController {

@IBOutlet weak var imagesBarItem: UITabBarItem!

override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.

if #available(iOS 11.0, *) {
let image = UIImage(named: "first_large")
imagesBarItem.largeContentSizeImage = image
} else {
// Fallback on earlier versions
}
}

override func didReceiveMemoryWarning() {

0 comments on commit 1f17508

Please sign in to comment.