Установите ограничения для uiview swift

view.addSubview(myView1)
myView1.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
    myView1.centerXAnchor.constraint(equalTo: view.centerXAnchor),
    myView1.centerYAnchor.constraint(equalTo: view.centerYAnchor),
    myView1.widthAnchor.constraint(equalToConstant: 100),
    myView1.heightAnchor.constraint(equalToConstant: 100),
])

# OR

view.addSubview(myView2)
    myView2.translatesAutoresizingMaskIntoConstraints = false

    NSLayoutConstraint.activate([
        myView2.leadingAnchor.constraint(equalTo: view.leadingAnchor,constant: 16),
        myView2.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor,constant: 16),
        myView2.widthAnchor.constraint(equalTo: view.widthAnchor, multiplier: 0.3),
        myView2.heightAnchor.constraint(equalTo: view.heightAnchor, multiplier: 0.3)
    ])
Ghaith Alzin