-
-
Save vmaraccini/ed177f2fb490d3754a7430191c91827a to your computer and use it in GitHub Desktop.
This file contains 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 | |
/** | |
**Contains the inteface elements of a screen or screen fragment** | |
Contains labels, buttons, etc and is responsible for the layout. | |
**Lifecycle:** | |
1. `init()` | |
2. `initialize()` *Add subviews* | |
3. `installConstraints()` *Layout* | |
- The methods themselves do nothing, it's up to the custom implementation | |
*/ | |
open class BaseView: UIView { | |
override init(frame: CGRect) { | |
super.init(frame: frame) | |
self.setup() | |
} | |
required public init?(coder aDecoder: NSCoder) { | |
super.init(coder: aDecoder) | |
self.setup() | |
} | |
required public init() { | |
super.init(frame: CGRect.zero) | |
self.setup() | |
} | |
/// Default implementation does nothing | |
open func initialize() {} | |
/// Default implementation does nothing | |
open func installConstraints() {} | |
// MARK: Private | |
fileprivate func setup() { | |
self.initialize() | |
self.installConstraints() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
🏅