forked from thiagoperes/IDMPhotoBrowser
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from cchen0312/master
iPhone X Support thiagoperes#282
- Loading branch information
Showing
6 changed files
with
151 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// | ||
// IDMUtils.h | ||
// PhotoBrowserDemo | ||
// | ||
// Created by Oliver ONeill on 2/12/17. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
|
||
@interface IDMUtils : NSObject | ||
+ (CGRect)adjustRect:(CGRect)rect forSafeAreaInsets:(UIEdgeInsets)insets forBounds:(CGRect)bounds adjustForStatusBar:(BOOL)adjust statusBarHeight:(int)statusBarHeight; | ||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// | ||
// IDMUtils.m | ||
// PhotoBrowserDemo | ||
// | ||
// Created by Oliver ONeill on 2/12/17. | ||
// | ||
|
||
#import "IDMUtils.h" | ||
|
||
@implementation IDMUtils | ||
/** | ||
* Adjust a rect to be moved into a safe area specified by `insets`. | ||
* | ||
* NOTE: this does not cover all cases. Given a rect it will reposition it if it | ||
* falls into an unsafe area according to `insets` and `bounds`. When | ||
* `adjustForStatusBar` is true, the rect y position will be based from the edge | ||
* of the safe area, otherwise it will be based from zero. This allows views to | ||
* sit behind the status bar. Status bar height is also used | ||
* to keep positioning consistent when toggling the status bar on and off | ||
*/ | ||
+ (CGRect)adjustRect:(CGRect)rect forSafeAreaInsets:(UIEdgeInsets)insets forBounds:(CGRect)bounds adjustForStatusBar:(BOOL)adjust statusBarHeight:(int)statusBarHeight { | ||
BOOL isLeft = rect.origin.x <= insets.left; | ||
// If the safe area is not specified via insets we should fall back to the | ||
// status bar height | ||
CGFloat insetTop = insets.top > 0 ? insets.top : statusBarHeight; | ||
// Don't adjust for y positioning when adjustForStatusBar is false | ||
BOOL isAtTop = (rect.origin.y <= insetTop); | ||
BOOL isRight = rect.origin.x + rect.size.width >= bounds.size.width - insets.right; | ||
BOOL isAtBottom = rect.origin.y + rect.size.height >= bounds.size.height - insets.bottom; | ||
if ((isLeft) && (isRight)) { | ||
rect.origin.x += insets.left; | ||
rect.size.width -= insets.right + insets.left; | ||
} else if (isLeft) { | ||
rect.origin.x += insets.left; | ||
} else if (isRight) { | ||
rect.origin.x -= insets.right; | ||
} | ||
// if we're adjusting for status bar then we should move the view out of | ||
// the inset | ||
if ((adjust) && (isAtTop) && (isAtBottom)) { | ||
rect.origin.y += insetTop; | ||
rect.size.height -= insets.bottom + insetTop; | ||
} else if ((adjust) && (isAtTop)) { | ||
rect.origin.y += insetTop; | ||
} else if ((isAtTop) && (isAtBottom)) { | ||
rect.size.height -= insets.bottom; | ||
} else if (isAtBottom) { | ||
rect.origin.y -= insets.bottom; | ||
} | ||
return rect; | ||
} | ||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,17 @@ | ||
source 'https://github.com/CocoaPods/Specs.git' | ||
|
||
# ignoring warning from pods | ||
platform :ios, '8.0' | ||
|
||
# ignore all warnings from all pods | ||
inhibit_all_warnings! | ||
|
||
target "PhotoBrowserDemo" do | ||
def all_pods | ||
pod 'SDWebImage', '~>3.7.1' | ||
pod 'DACircularProgress' | ||
pod 'pop' | ||
end | ||
|
||
pod 'SDWebImage' | ||
pod 'DACircularProgress' | ||
pod 'pop' | ||
|
||
target "PhotoBrowserDemo" do | ||
all_pods | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,20 @@ | ||
PODS: | ||
- DACircularProgress (2.3.1) | ||
- pop (1.0.9) | ||
- SDWebImage (3.8.2): | ||
- SDWebImage/Core (= 3.8.2) | ||
- SDWebImage/Core (3.8.2) | ||
- SDWebImage (3.7.6): | ||
- SDWebImage/Core (= 3.7.6) | ||
- SDWebImage/Core (3.7.6) | ||
|
||
DEPENDENCIES: | ||
- DACircularProgress | ||
- pop | ||
- SDWebImage | ||
- SDWebImage (~> 3.7.1) | ||
|
||
SPEC CHECKSUMS: | ||
DACircularProgress: 4dd437c0fc3da5161cb289e07ac449493d41db71 | ||
pop: f667631a5108a2e60d9e8797c9b32ddaf2080bce | ||
SDWebImage: 098e97e6176540799c27e804c96653ee0833d13c | ||
SDWebImage: c325cf02c30337336b95beff20a13df489ec0ec9 | ||
|
||
PODFILE CHECKSUM: 7c9b8bb160246eb04b56feab0ec4a8fb149d5fa3 | ||
PODFILE CHECKSUM: b7a7dde22263842dee0946aa36312edfaf9acf0c | ||
|
||
COCOAPODS: 1.0.1 | ||
COCOAPODS: 1.4.0 |