Skip to content

Commit 0558e09

Browse files
committed
Add back iOS 8+ compatibility
1 parent 5040ce4 commit 0558e09

File tree

5 files changed

+54
-17
lines changed

5 files changed

+54
-17
lines changed

ImagePickerSheetController.podspec

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,10 @@ Pod::Spec.new do |s|
5656
# the deployment target. You can optionally include the target after the platform.
5757
#
5858

59-
s.platform = :ios, "9.0"
59+
s.platform = :ios, "8.0"
6060

6161
# When using multiple platforms
62-
s.ios.deployment_target = "9.0"
62+
s.ios.deployment_target = "8.0"
6363
# s.osx.deployment_target = "10.7"
6464

6565

@@ -114,6 +114,6 @@ Pod::Spec.new do |s|
114114
# you can include multiple dependencies to ensure it works.
115115

116116
s.requires_arc = true
117-
117+
118118

119119
end

ImagePickerSheetController/ImagePickerSheetController.xcodeproj/project.pbxproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,7 @@
564564
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
565565
GCC_WARN_UNUSED_FUNCTION = YES;
566566
GCC_WARN_UNUSED_VARIABLE = YES;
567-
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
567+
IPHONEOS_DEPLOYMENT_TARGET = 8.3;
568568
MTL_ENABLE_DEBUG_INFO = YES;
569569
ONLY_ACTIVE_ARCH = YES;
570570
SDKROOT = iphoneos;
@@ -608,7 +608,7 @@
608608
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
609609
GCC_WARN_UNUSED_FUNCTION = YES;
610610
GCC_WARN_UNUSED_VARIABLE = YES;
611-
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
611+
IPHONEOS_DEPLOYMENT_TARGET = 8.3;
612612
MTL_ENABLE_DEBUG_INFO = NO;
613613
SDKROOT = iphoneos;
614614
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
@@ -630,7 +630,7 @@
630630
FRAMEWORK_SEARCH_PATHS = "";
631631
INFOPLIST_FILE = ImagePickerSheetController/Info.plist;
632632
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
633-
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
633+
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
634634
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
635635
PRODUCT_BUNDLE_IDENTIFIER = "ch.laurinbrandner.$(PRODUCT_NAME:rfc1034identifier)";
636636
PRODUCT_NAME = "$(TARGET_NAME)";
@@ -650,7 +650,7 @@
650650
FRAMEWORK_SEARCH_PATHS = "";
651651
INFOPLIST_FILE = ImagePickerSheetController/Info.plist;
652652
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
653-
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
653+
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
654654
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
655655
PRODUCT_BUNDLE_IDENTIFIER = "ch.laurinbrandner.$(PRODUCT_NAME:rfc1034identifier)";
656656
PRODUCT_NAME = "$(TARGET_NAME)";

ImagePickerSheetController/ImagePickerSheetController/AnimationController.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ class AnimationController: NSObject {
5656
extension AnimationController: UIViewControllerAnimatedTransitioning {
5757

5858
func transitionDuration(transitionContext: UIViewControllerContextTransitioning?) -> NSTimeInterval {
59+
guard #available(iOS 9, *) else {
60+
return 0.3
61+
}
62+
5963
return 0.25
6064
}
6165

ImagePickerSheetController/ImagePickerSheetController/ImagePickerSheetController.swift

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,10 @@ public class ImagePickerSheetController: UIViewController {
111111
private var maximumPreviewHeight: CGFloat = 129
112112

113113
private var previewCheckmarkInset: CGFloat {
114+
guard #available(iOS 9, *) else {
115+
return 3.5
116+
}
117+
114118
return 12.5
115119
}
116120

@@ -231,7 +235,9 @@ public class ImagePickerSheetController: UIViewController {
231235
}
232236

233237
let fetchLimit = 50
234-
options.fetchLimit = fetchLimit
238+
if #available(iOS 9, *) {
239+
options.fetchLimit = fetchLimit
240+
}
235241

236242
let result = PHAsset.fetchAssetsWithOptions(options)
237243
let requestOptions = PHImageRequestOptions()
@@ -355,8 +361,16 @@ public class ImagePickerSheetController: UIViewController {
355361
reloadCurrentPreviewHeight(invalidateLayout: false)
356362

357363
view.setNeedsLayout()
358-
359-
UIView.animateWithDuration(0.2, animations: {
364+
365+
let animationDuration: NSTimeInterval
366+
if #available(iOS 9, *) {
367+
animationDuration = 0.2
368+
}
369+
else {
370+
animationDuration = 0.3
371+
}
372+
373+
UIView.animateWithDuration(animationDuration, animations: {
360374
self.view.layoutIfNeeded()
361375
self.sheetCollectionView.collectionViewLayout.invalidateLayout()
362376
}, completion: completion)

ImagePickerSheetController/ImagePickerSheetController/Sheet/SheetController.swift

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,14 @@ class SheetController: NSObject {
7777
return previewHeight
7878
}
7979

80-
let actionItemHeight: CGFloat = 57
80+
let actionItemHeight: CGFloat
81+
82+
if #available(iOS 9, *) {
83+
actionItemHeight = 57
84+
}
85+
else {
86+
actionItemHeight = 50
87+
}
8188

8289
let insets = attributesForItemAtIndexPath(indexPath).backgroundInsets
8390
return actionItemHeight + insets.top + insets.bottom
@@ -89,6 +96,10 @@ class SheetController: NSObject {
8996
// MARK: - Design
9097

9198
private func attributesForItemAtIndexPath(indexPath: NSIndexPath) -> (corners: RoundedCorner, backgroundInsets: UIEdgeInsets) {
99+
guard #available(iOS 9, *) else {
100+
return (.None, UIEdgeInsets())
101+
}
102+
92103
let cornerRadius: CGFloat = 13
93104
let innerInset: CGFloat = 4
94105
var indexPaths = allIndexPaths()
@@ -120,10 +131,11 @@ class SheetController: NSObject {
120131
}
121132

122133
private func fontForAction(action: ImagePickerAction) -> UIFont {
123-
if action.style == .Cancel {
124-
return UIFont.boldSystemFontOfSize(21)
134+
guard #available(iOS 9, *), action.style == .Cancel else {
135+
return UIFont.systemFontOfSize(21)
125136
}
126-
return UIFont.systemFontOfSize(21)
137+
138+
return UIFont.boldSystemFontOfSize(21)
127139
}
128140

129141
// MARK: - Actions
@@ -212,9 +224,16 @@ extension SheetController: UICollectionViewDataSource {
212224

213225
// iOS specific design
214226
(cell.roundedCorners, cell.backgroundInsets) = attributesForItemAtIndexPath(indexPath)
215-
cell.normalBackgroundColor = UIColor(white: 0.97, alpha: 1)
216-
cell.highlightedBackgroundColor = UIColor(white: 0.92, alpha: 1)
217-
cell.separatorColor = UIColor(white: 0.84, alpha: 1)
227+
if #available(iOS 9, *) {
228+
cell.normalBackgroundColor = UIColor(white: 0.97, alpha: 1)
229+
cell.highlightedBackgroundColor = UIColor(white: 0.92, alpha: 1)
230+
cell.separatorColor = UIColor(white: 0.84, alpha: 1)
231+
}
232+
else {
233+
cell.normalBackgroundColor = .whiteColor()
234+
cell.highlightedBackgroundColor = UIColor(white: 0.85, alpha: 1)
235+
cell.separatorColor = UIColor(white: 0.784, alpha: 1)
236+
}
218237

219238
return cell
220239
}

0 commit comments

Comments
 (0)