Skip to content

Commit bcd2a3e

Browse files
committed
If one of the constraint items is a layout guide - the constraint will subtract it's length. #8
1 parent c6ccdcf commit bcd2a3e

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

KeyboardConstraint/KeyboardAdjustConstraint.m

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,18 @@ - (void)_keyboardDidChangeVisible:(NSNotification *)notification
5959
keyboardHeight = intersection.size.height;
6060
}
6161

62+
// If one of the constraint items is a layout guide; subtract it's length:
63+
64+
if (notification.name == UIKeyboardWillShowNotification) {
65+
if ([self.firstItem conformsToProtocol:@protocol(UILayoutSupport)]) {
66+
id<UILayoutSupport> layoutGuide = self.firstItem;
67+
keyboardHeight -= layoutGuide.length;
68+
} else if ([self.secondItem conformsToProtocol:@protocol(UILayoutSupport)]) {
69+
id<UILayoutSupport> layoutGuide = self.secondItem;
70+
keyboardHeight -= layoutGuide.length;
71+
}
72+
}
73+
6274
if (superview) {
6375
//Force layout before animation...
6476
[CATransaction begin];

0 commit comments

Comments
 (0)