Skip to content

Instantly share code, notes, and snippets.

@tatey
Last active March 6, 2019 04:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tatey/d83be8d623a0a51a1cc91133a5459e4f to your computer and use it in GitHub Desktop.
Save tatey/d83be8d623a0a51a1cc91133a5459e4f to your computer and use it in GitHub Desktop.
import UIKit
class LayoutMarginsHackView: UIView {
var actualLayoutMargins: UIEdgeInsets = .zero
override var layoutMargins: UIEdgeInsets {
set {
if #available(iOS 11, *) {
super.layoutMargins = newValue
} else {
super.layoutMargins = actualLayoutMargins
}
}
get {
return super.layoutMargins
}
}
}
import UIKit
protocol LayoutMarginsDidChangeHackViewDelegate: class {
func viewLayoutMarginsDidChange()
}
class LayoutMarginsDidChangeHackView: UIView {
weak var delegate: LayoutMarginsDidChangeHackViewDelegate?
override func layoutMarginsDidChange() {
super.layoutMarginsDidChange()
if #available(iOS 11, *) {
// no-op
} else {
delegate?.viewLayoutMarginsDidChange()
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment