Этого можно добиться с помощью autolayout, см. Пример ниже.
let view0 = StarClass.createMyClassView()
view0.translatesAutoresizingMaskIntoConstraints = false // Enables autolayout
parent.addSubview(view0)
let view1 = StarClass.createMyClassView()
view1.translatesAutoresizingMaskIntoConstraints = false
parent.addSubview(view1)
NSLayoutConstraint.activate([
view0.leftAnchor.constraint(equalTo: parent.leftAnchor), // Set layout for view0
view0.rightAnchor.constraint(equalTo: parent.rightAnchor),
view0.topAnchor.constraint(equalTo: parent.topAnchor),
view0.heightAnchor.constraint(equalToConstant: 100),
view1.leftAnchor.constraint(equalTo: parent.leftAnchor), // Set layout for view1
view1.rightAnchor.constraint(equalTo: parent.rightAnchor),
view1.topAnchor.constraint(equalTo: view0.bottomAnchor), // below view0
view1.heightAnchor.constraint(equalToConstant: 100)
])