Last active
March 6, 2019 04:43
-
-
Save tatey/d83be8d623a0a51a1cc91133a5459e4f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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