Skip to content

Instantly share code, notes, and snippets.

@anirudhamahale
Last active July 19, 2017 04:03
Show Gist options
  • Save anirudhamahale/2973d14b640f27957c3ca716d4405289 to your computer and use it in GitHub Desktop.
Save anirudhamahale/2973d14b640f27957c3ca716d4405289 to your computer and use it in GitHub Desktop.
Create custome view.
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