Skip to content

Commit

Permalink
If one of the constraint items is a layout guide - the constraint wil…
Browse files Browse the repository at this point in the history
…l subtract it's length. #8
  • Loading branch information
markst committed Oct 12, 2017
1 parent c6ccdcf commit bcd2a3e
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions KeyboardConstraint/KeyboardAdjustConstraint.m
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,18 @@ - (void)_keyboardDidChangeVisible:(NSNotification *)notification
keyboardHeight = intersection.size.height;
}

// If one of the constraint items is a layout guide; subtract it's length:

if (notification.name == UIKeyboardWillShowNotification) {
if ([self.firstItem conformsToProtocol:@protocol(UILayoutSupport)]) {
id<UILayoutSupport> layoutGuide = self.firstItem;
keyboardHeight -= layoutGuide.length;
} else if ([self.secondItem conformsToProtocol:@protocol(UILayoutSupport)]) {
id<UILayoutSupport> layoutGuide = self.secondItem;
keyboardHeight -= layoutGuide.length;
}
}

if (superview) {
//Force layout before animation...
[CATransaction begin];
Expand Down

0 comments on commit bcd2a3e

Please sign in to comment.