Application of xib file in ios programming

Create a xib file, you can also set it by dragging and dropping

Then instantiate it through code, and then add it to the view.

let bundle = Bundle(for: type(of: self))

    UINib(nibName: "HeaderView", bundle: bundle).instantiate(withOwner: self, options: nil)

    

    addSubview(view)

    view.frame = bounds


I wrote it myself as a memo, please forgive me if it is not clear.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325542164&siteId=291194637