I have added the
myView.translatesAutoresizingMaskIntoConstraints = false
code line to my code.
import UIKit
class ViewController: UIViewController {
var myView = UIView()
override func viewDidLoad() {
super.viewDidLoad()
myView.frame.size.width = 100
myView.frame.size.height = 100
myView.backgroundColor = .green
view.addSubview(myView)
myView.translatesAutoresizingMaskIntoConstraints = false
let margins = view.layoutMarginsGuide
myView.trailingAnchor.constraint(equalTo: margins.trailingAnchor).isActive = true
}
}
But now. i get a blank screen.
Why is this happening?