I'm trying to load nib file to view inside collectionViewController as parallax Header, but after loading the view the width of the view is 0.0 and it's not presenting.If I load any other view the width is ok but the width of this view changes to zero after loading.here is my code.
class CastHeader: UIView{
private func commonInit() {
guard let view = Bundle.main.loadNibNamed("CastHeader", owner: self, options: nil)![0] as? UIView else{return}
addSubview(view)
view.translatesAutoresizingMaskIntoConstraints = false
let bindings = ["view": view]
addConstraints(NSLayoutConstraint.constraints(withVisualFormat: "H:|[view]|", options:[], metrics:nil, views: bindings))
addConstraints(NSLayoutConstraint.constraints(withVisualFormat: "V:|[view]|", options:[], metrics:nil, views: bindings))
}
// MARK: User interface
override init(frame: CGRect) {
super.init(frame: frame)
commonInit()
awakeFromNib()
}
required init?(coder: NSCoder) {
super.init(coder: coder)
commonInit()
awakeFromNib()
}
}
is there any thouts on that ? thank you in advance