Skip to content

Instantly share code, notes, and snippets.

@vialyx
Last active October 11, 2018 03:29
Show Gist options
  • Save vialyx/fad211eba1a93ea66f1ad940e1196a02 to your computer and use it in GitHub Desktop.
Save vialyx/fad211eba1a93ea66f1ad940e1196a02 to your computer and use it in GitHub Desktop.
class FullscreenButton: UIButton {
// Convenience initializer
convenience init(_ screen: UIScreen) {
// Reusing Designated initializer
self.init(frame: screen.bounds)
}
// Initializer overriding
override init(frame: CGRect) {
super.init(frame: frame)
}
// Required initializer
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
// Failable Initializer
init?(_ screen: UIScreen, with type: UIButton.ButtonType) {
guard screen.bounds.width > 320 else { return nil }
super.init(frame: screen.bounds)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment