Consider that a view is added as subview to the main view as follows:
override func viewDidLoad()
{
super.viewDidLoad()
let subview = UIView(frame: CGRect(x: 150, y: 350, width: 20, height: 20))
subview.backgroundColor = UIColor.blue
self.view.addSubview(subview)
}
When the device goes from portrait to landscape, the default behaviour is that the subview is moved in a way that its horizontal and vertical distance from the upper left corner of the device, remain unchanged. How can i change this so that its horizontal and vertical distance from the center of the device, remain unchanged? Thank you