Skip to content

Commit

Permalink
Merge pull request #179 from wowlocal/master
Browse files Browse the repository at this point in the history
Fixed incorrect displaying with iPhone X.
  • Loading branch information
zenangst authored Oct 17, 2017
2 parents 3867fc9 + 6c00be5 commit c720e39
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
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

0 comments on commit c720e39

Please sign in to comment.