-
Notifications
You must be signed in to change notification settings - Fork 642
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add iPhone X support Fix done button moving when the status bar is hidden I've tried to keep the use of doneButtonTopInset to be the same even with the new requirements for iPhone X Fix iPhone X support bugs with orientation There were issue when switching between landscape and portrait orientation specifically to do with changes iPhone X safe area insets. Fix present animation Cleanup tests Fix done button status bar bug When the status bar is hidden, its height property is set to zero, this makes it difficult to position elements relative to that without them moving when its hidden. To fix this I've hardcoded the value to twenty. There wasn't an easy way of getting this number without displaying the status bar Change present animation to simpler calculation Update IDMUtils header
- Loading branch information
1 parent
2123703
commit be10bd0
Showing
7 changed files
with
441 additions
and
10 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 |
Oops, something went wrong.