Skip to content

Instantly share code, notes, and snippets.

@bfernandesbfs
Created October 4, 2016 19:16
Show Gist options
  • Save bfernandesbfs/6fb145d542937e86264ee665f825a5cd to your computer and use it in GitHub Desktop.
Save bfernandesbfs/6fb145d542937e86264ee665f825a5cd to your computer and use it in GitHub Desktop.
override init(frame: CGRect) {
super.init(frame: frame)
loadViewFromNib()
}
required public init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
loadViewFromNib()
}
private func loadViewFromNib() {
let bundle = NSBundle(forClass: self.dynamicType)
let nib = UINib(nibName: String(MY_VIEW_CLASS_NAME_ID_Storyboard), bundle: bundle)
let view = nib.instantiateWithOwner(self, options: nil)[0] as! UIView
view.frame = bounds
view.autoresizingMask = [UIViewAutoresizing.FlexibleWidth , UIViewAutoresizing.FlexibleHeight]
addSubview(view)
backgroundColor = UIColor.clearColor()
view.backgroundColor = UIColor.clearColor()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment