Skip to content

Commit 0b5897a

Browse files
authored
Merge pull request #37 from wallacesky/j-1.2.3
Support iPhone X navigation bar
2 parents 6d582d1 + 269402f commit 0b5897a

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

INSPhotoGallery/INSPhotosOverlayView.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,12 @@ open class INSPhotosOverlayView: UIView , INSPhotosOverlayViewable {
166166
navigationBar.items = [navigationItem]
167167
addSubview(navigationBar)
168168

169-
let topConstraint = NSLayoutConstraint(item: navigationBar, attribute: .top, relatedBy: .equal, toItem: self, attribute: .top, multiplier: 1.0, constant: 0.0)
169+
let topConstraint: NSLayoutConstraint
170+
if #available(iOS 11.0, *) {
171+
topConstraint = NSLayoutConstraint(item: navigationBar, attribute: .top, relatedBy: .equal, toItem: self.safeAreaLayoutGuide, attribute: .top, multiplier: 1.0, constant: 0.0)
172+
} else {
173+
topConstraint = NSLayoutConstraint(item: navigationBar, attribute: .top, relatedBy: .equal, toItem: self, attribute: .top, multiplier: 1.0, constant: 0.0)
174+
}
170175
let widthConstraint = NSLayoutConstraint(item: navigationBar, attribute: .width, relatedBy: .equal, toItem: self, attribute: .width, multiplier: 1.0, constant: 0.0)
171176
let horizontalPositionConstraint = NSLayoutConstraint(item: navigationBar, attribute: .centerX, relatedBy: .equal, toItem: self, attribute: .centerX, multiplier: 1.0, constant: 0.0)
172177
self.addConstraints([topConstraint,widthConstraint,horizontalPositionConstraint])

0 commit comments

Comments
 (0)