What you are asking cannot be done that way, only you can create new window with different frame but to use in another device's screen. But you can change you current view controllers view frames according calculating the aspect ratio of each device and changing the height of you view according to that, or you can make the rect with the local dimensions too.
Make extension use it everywhere:
e.g:
extension UIViewController {
/* With exact value */
func convertTo3_5inch() {
// 320 × 480
if UIScreen.main.bounds.height >= 480 {
self.view.frame = CGRect(x: 0, y: 0, width: 320, height: 480)
self.view.layoutIfNeeded()
}
}
/* With Ratio */
func convertTo16_9ratio() {
// 320 * 568
if UIScreen.main.bounds.height >= 568 {
self.view.frame = CGRect(x: 0, y: 0, width: UIScreen.main.bounds.width, height: (UIScreen.main.bounds.width*16)/9)
self.view.layoutIfNeeded()
} else {
print("Screen size smaller than the size your are converting to")
}
}
/* call this func in button */
func changeAction() {
let action = UIAlertController(title: "Options", message: nil, preferredStyle: .actionSheet)
action.addAction(UIAlertAction(title: "3.5inch", style: .default, handler: { (action) in
self.convertTo3_5inch()
}))
action.addAction(UIAlertAction(title: "5to8plus", style: .default, handler: { (action) in
self.convertTo16_9ratio()
}))
self.present(action, animated: true, completion: .none)
}
}
Customize according to your need,