Skip to content

Instantly share code, notes, and snippets.

@RomanVolkov
Created March 21, 2017 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RomanVolkov/7337b43f5de68bfcaf9758363e96dcaa to your computer and use it in GitHub Desktop.
Save RomanVolkov/7337b43f5de68bfcaf9758363e96dcaa to your computer and use it in GitHub Desktop.
Designable XIB. Set XIB's owner to ViewName, connect top view to ViewName.view outlet
final class ViewName: UIView {
@IBOutlet weak var view: UIView!
override init(frame: CGRect) {
super.init(frame: frame)
setupView()
}
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
setupView()
}
override func awakeFromNib() {
super.awakeFromNib()
}
private func setupView() {
let bundle = Bundle(for: type(of: self))
UINib(nibName: "DetailedDropdownView", bundle: bundle) //xib name
.instantiate(withOwner: self, options: nil)
addSubview(self.view)
self.view.frame = bounds
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment