view = nib.instantiateWithOwner(nil, options: nil).first as? RandomView ! import Reusable class RandomView: UIView, NibLoadable { // The rest of the view code goes here } let view = RandomView.loadFromNib()
-> AnyObject? { if subviews.count > 0 { return super.awakeAfterUsingCoder(aDecoder) } let view = self.dynamicType.loadFromNib() // Transfer some common properties view.translatesAutoresizingMaskIntoConstraints = translatesAutoresizingMaskIntoConstraints // frame, backgroundColor, alpha, ... // Transfer Constraints for placeholderConstraint in constraints { // Check out the example project } return view }