[英]Is there a way to simulate a smaller iPhone on my Plus?
我有用於開發的iPhone Plus。 我擔心自己的應用會局促,或者在SE等4英寸手機上沒有良好的UI。 有沒有辦法在Plus上模擬4英寸手機? 我想這會在屏幕的頂部和側面留下空白。
模擬器不起作用,因為比例錯誤。 一切看起來都更大。 很難在模擬器上測試觸摸手勢是否自然。 最后,它是一個相機應用程序,因此它不能在模擬器上運行。
我可以使用第三方應用程序或庫來做到這一點。
您可以使用容器視圖控制器輕松地對此進行模擬:
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")
}
}
然后,在您的應用程序委托中,將其設置為您的根視圖控制器。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.