Swift Initialize A View

[Solved] Swift Initialize A View | Swift - Code Explorer | yomemimo.com
Question : swift initialize a view

Answered by : ill-ibex-i5hmphyd87cu

class CustomView: UIView { var customParam: customType var container = UIView() required init(customParamArg: customType) { self.customParam = customParamArg super.init(frame: .zero) // Setting up the view can be done here setupView() } required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") } func setupView() { // Can do the setup of the view, including adding subviews setupConstraints() } func setupConstraints() { // setup custom constraints as you wish }
}

Source : https://stackoverflow.com/questions/24339145/how-do-i-write-a-custom-init-for-a-uiview-subclass-in-swift | Last Update : Wed, 11 Nov 20

Answers related to swift initialize a view

Code Explorer Popular Question For Swift