我有一个我用于开发的iPhone Plus。我担心我的应用程序会变得狭窄,或者在SE等4英寸手机上没有良好的用户界面。有没有办法模拟Plus上的4英寸手机?我想它会在屏幕的顶部和两侧留下空白区域。
模拟器不起作用,因为刻度错误。一切都显得更大。在模拟器上测试触摸手势以查看它们是否感觉自然也很难。最后,它是一个相机应用程序,因此它不能在模拟器上运行。
我可以使用第三方应用程序或库来执行此操作。
答案 0 :(得分:0)
您可以使用容器视图控制器轻松模拟它:
class FourInchViewController: UIViewController {
init(child: UIViewController) {
self.child = child
super.init(nibName: nil, bundle: nil)
addChildViewController(child)
}
// Internals:
private let child: UIViewController
override func loadView() {
let black = UIView()
black.backgroundColor = .black
view = black
view.addSubview(child.view)
}
override func viewWillLayoutSubviews() {
let size = view.bounds.size
let w = CGFloat(320), h = CGFloat(568)
child.view.frame = CGRect(
x:(size.width - w)/2,
y:size.height - h,
width: w,
height: h)
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}
然后,在您的app委托中,将其设置为根视图控制器。