将iPhone X布局支持添加到旧的Xcode 7/Swift 2项目 [英] Add iPhone X layout support to old Xcode 7 / Swift 2 project
问题描述
我有什么?
一个使用Swift 2并在Xcode 7上没有任何问题的情况下构建/运行的老项目.它具有很多依赖关系和复杂的体系结构,这使得迁移到swift 3/4(在短时间内)变得很复杂./p>
当应用程序在iPhone X上运行时,它的屏幕顶部和底部都有黑条(大小与iPhone 6/7/8相似)
我需要什么?
我需要使该应用程序在iPhone X上运行,并且屏幕顶部和底部(全屏)上没有黑条,并且不更新整个项目.有什么方法可以实现吗?
我尝试了什么?
- 直接对包含的超级视图而不是layoutGuide进行约束
- 删除launchScreen资产并仅坚持使用LaunchScreen.xib
只有两种方法可以删除黑边,以获取较新的设备尺寸:
- 以新尺寸启动屏幕图像资产
- 启动屏幕故事板
而且,您真不走运,因为这两种解决方案都需要Xcode 9才能支持iPhone X大小.因此,您必须至少要使用Swift 3.2.
What I have?
An old project using Swift 2 and building/running without any issue on Xcode 7. It has a lot of dependencies and sophisticated architecture which makes it complicated to migrate to swift 3/4 (in a short period of time).
When app is running on iPhone X it has black bars on top and bottom of the sreen (sizing like on iPhone 6/7/8)
What I need?
I need to make the app running on iPhone X without black bars on top and bottom of the screen (fullscreen) without updating whole project. Are there any ways making it possible?
What I've tried?
- Making constraints directly to the containing superviews and not the layoutGuide
- Removing launchScreen assets and sticking only to LaunchScreen.xib
There are only two ways to remove black bars for a newer device size:
- Launchscreen images assets with the new size
- Launchscreen storyboard
And, well, you're out of luck, because both solutions require Xcode 9 for iPhone X size support. So you must go for Swift 3.2 at least.
这篇关于将iPhone X布局支持添加到旧的Xcode 7/Swift 2项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!