Skip to content

Commit bb575b0

Browse files
committed
🐛 :: keyboardMargins return UIEdgeInsets
1 parent 1a3b54c commit bb575b0

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

Example/.DS_Store

0 Bytes
Binary file not shown.

Sources/PinLayout.swift

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,14 @@ public class PinLayout<View: Layoutable> {
8888
public var keyboardMargins: PEdgeInsets {
8989
guard #available(iOS 15.0, *) else { return .zero }
9090
guard let view = view as? UIView else { return .zero }
91-
return view.keyboardLayoutGuide
91+
92+
let layoutFrame = view.keyboardLayoutGuide.layoutFrame
93+
guard !layoutFrame.isEmpty else { return .zero }
94+
95+
return UIEdgeInsets(top: layoutFrame.origin.y,
96+
left: layoutFrame.origin.x,
97+
bottom: view.frame.height - layoutFrame.origin.y - layoutFrame.height,
98+
right: view.frame.width - layoutFrame.origin.x - layoutFrame.width)
9299
}
93100
#endif
94101

0 commit comments

Comments
 (0)