Xcode 6 & Swift: Black bars appear above and below the viewcontroller on iOS 7 iPhone 5 device

后端 未结 5 513
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-02-06 02:42

I created a single view test app and tried running it on my iPhone 5 with iOS 7 installed. It looks like the screen is set to the iPhone 4 size and black bars appear above and b

5条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-02-06 03:38

    In order to solve this problem you have to create launch-screen images for the devices your app supports.

    When starting a new app:

    For instance let's say your app supports iPhones > 4s, so iPhone: 4s, 5, 5s, 6 and 6plus.

    Make sure to make launch-images which have the following dimensions:

    • iPhone4s = 640 × 960
    • iPhone5, 5s = 640 × 1136
    • iPhone6 = 750 x 1134
    • iPhone6plus = 1242 x 2208

    For more info about iOS screen dimensions, see this helpful chart

    Select your project and then the general settings:

    Select or make launch screens in the general section when clicked on your project.

    enter image description here

    And then make sure you add or select an Launch-image asset: enter image description here

    Go to images.xcassets and select LaunchImage at the left, then select the devices your app supports (at the right)

    enter image description here

    Make sure you put your images on the right spot, you can select the dashed square and see in the attributes inspector (right section on screen) what dimensions your image needs to meet.

    Now when simulating your app all black bars have disappeared.

提交回复
热议问题