Last active
July 19, 2017 04:03
-
-
Save anirudhamahale/2973d14b640f27957c3ca716d4405289 to your computer and use it in GitHub Desktop.
Create custome view.
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
class CustomeView: UIView { | |
// This view is the xib's view. | |
@IBOutlet var view: UIView! | |
// MARK: - Initializers | |
override init(frame: CGRect) { | |
super.init(frame: frame) | |
setupView() | |
} | |
required init?(coder aDecoder: NSCoder) { | |
super.init(coder: aDecoder) | |
setupView() | |
} | |
// MARK: - Private Helper Methods | |
// Performs the initial setup. | |
fileprivate func setupView() { | |
// passing nil in the bundle will take the file from the app's main bundle. | |
// nibName is the name of the xib that you have created. | |
UINib(nibName: "CustomeView", bundle: nil).instantiate(withOwner: self, options: nil) | |
view.frame = self.bounds | |
addSubview(view) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment