Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed incorrect displaying with iPhone X. #179

Merged
merged 2 commits into from
Oct 17, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions Source/ShoutFactory.swift
Original file line number Diff line number Diff line change
Expand Up @@ -174,17 +174,27 @@ open class ShoutView: UIView {
if subtitleLabel.text?.isEmpty ?? true {
titleLabel.center.y = imageView.center.y - 2.5
}

frame = CGRect(x: 0, y: 0, width: totalWidth, height: internalHeight + Dimensions.touchOffset)
if #available(iOS 11.0, *) {
frame = CGRect(x: 0, y: self.safeAreaInsets.top, width: totalWidth, height: internalHeight + Dimensions.touchOffset)
} else {
frame = CGRect(x: 0, y: 0, width: totalWidth, height: internalHeight + Dimensions.touchOffset)
}
}

// MARK: - Frame

open override var frame: CGRect {
didSet {
backgroundView.frame = CGRect(x: 0, y: 0,
width: frame.size.width,
height: frame.size.height - Dimensions.touchOffset)
if #available(iOS 11.0, *) {
backgroundView.frame = CGRect(x: 0, y: self.safeAreaInsets.top,
width: frame.size.width,
height: frame.size.height - Dimensions.touchOffset)
} else {
// Fallback on earlier versions
backgroundView.frame = CGRect(x: 0, y: 0,
width: frame.size.width,
height: frame.size.height - Dimensions.touchOffset)
}

indicatorView.frame = CGRect(x: (backgroundView.frame.size.width - Dimensions.indicatorWidth) / 2,
y: backgroundView.frame.height - Dimensions.indicatorHeight - 5,
Expand Down
6 changes: 6 additions & 0 deletions Source/WhistleFactory.swift
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,14 @@ open class WhistleFactory: UIViewController {
titleLabel.sizeToFit()
}

if #available(iOS 11.0, *) {
whistleWindow.frame = CGRect(x: 0, y: self.view.safeAreaInsets.top, width: labelWidth,
height: titleLabelHeight)
} else {
// Fallback on earlier versions
whistleWindow.frame = CGRect(x: 0, y: 0, width: labelWidth,
height: titleLabelHeight)
}
view.frame = whistleWindow.bounds
titleLabel.frame = view.bounds
}
Expand Down