Unable to make launch screen image full screen even with constraints

Raihan Iqbal 121 Reputation points
2020-12-30T09:58:27.9+00:00

I created a storyboard for my launch screen and set the necessary constraints however it still displays the status bar at the top.

<scenes>
        <scene sceneID="199">
            <objects>
                <viewController id="200" sceneMemberID="viewController">
                    <layoutGuides>
                        <viewControllerLayoutGuide type="top" id="197"/>
                        <viewControllerLayoutGuide type="bottom" id="198"/>
                    </layoutGuides>
                    <view key="view" contentMode="scaleToFill" id="201">
                        <rect key="frame" x="0.0" y="0.0" width="414" height="736"/>
                        <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                        <color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
                        <subviews>
                            <imageView id="204" image="LaunchImages" userInteractionEnabled="NO" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" misplaced="YES">
                                <rect key="frame" x="0.0" y="0.0" width="414" height="736"/>
                                <rect key="contentStretch" x="0.0" y="0.0" width="0.0" height="0.0"/>
                            </imageView>
                        </subviews>
                        <constraints>
                            <constraint id="454" firstItem="204" firstAttribute="top" secondItem="201" secondAttribute="topMargin"/>
                            <constraint id="455" firstItem="204" firstAttribute="leading" secondItem="201" secondAttribute="leadingMargin"/>
                            <constraint id="456" firstAttribute="trailingMargin" secondItem="204" secondAttribute="trailing"/>
                            <constraint id="458" firstAttribute="bottomMargin" secondItem="204" secondAttribute="bottom"/>
                        </constraints>
                    </view>
                </viewController>
                <placeholder placeholderIdentifier="IBFirstResponder" id="202" userLabel="First Responder" sceneMemberID="firstResponder"/>
            </objects>
            <point key="canvasLocation" x="-146" y="-398"/>
        </scene>

Does the image need to be of higher resolution?

Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,146 questions
0 comments No comments
{count} votes

Accepted answer
  1. Raihan Iqbal 121 Reputation points
    2020-12-31T05:11:43+00:00

    I was able to solve this by just adding width and height constraints and setting the content mode of the ImageView to AspectFill. If the launch image is from the asset catalog then iOS will automatically pick the right image. The final storyboard XML should look something like this:

    <scene sceneID="914">
                <objects>
                    <viewController id="915" sceneMemberID="viewController">
                        <layoutGuides>
                            <viewControllerLayoutGuide type="top" id="912"/>
                            <viewControllerLayoutGuide type="bottom" id="913"/>
                        </layoutGuides>
                        <view key="view" contentMode="scaleToFill" id="916">
                            <rect key="frame" x="0.0" y="0.0" width="414" height="736"/>
                            <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                            <color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
                            <subviews>
                                <imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" id="919" translatesAutoresizingMaskIntoConstraints="NO" misplaced="YES" ambiguous="YES" image="LaunchImages">
                                    <rect key="frame" x="87" y="292" width="414" height="736"/>
                                </imageView>
                            </subviews>
                            <constraints>
                                <constraint id="921" firstItem="919" firstAttribute="height" secondItem="916" secondAttribute="height"/>
                                <constraint id="922" firstItem="919" firstAttribute="width" secondItem="916" secondAttribute="width"/>
                            </constraints>
                        </view>
                    </viewController>
                    <placeholder placeholderIdentifier="IBFirstResponder" id="917" userLabel="First Responder" sceneMemberID="firstResponder"/>
                </objects>
                <point key="canvasLocation" x="-197" y="-378"/>
            </scene>
    
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Lucas Zhang - MSFT 336 Reputation points
    2020-12-30T10:26:33.28+00:00

    Hello,

    Welcome to our Microsoft Q&A platform!

    By adding proper constraint you will get your expected result. Add aspectRatio constraint to UIImageView.

    You could open the Storyboard with Xcode and set it like following

    52195-lunma.png

    All constraints as per

    52291-8ulxx.png

    Best Regards,

    Lucas Zhang

    If the response is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.