Skip to content

Instantly share code, notes, and snippets.

@bhallionOhbibi
Last active May 14, 2020 14:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bhallionOhbibi/a2385077fe9b5e3013817f39055127bb to your computer and use it in GitHub Desktop.
Save bhallionOhbibi/a2385077fe9b5e3013817f39055127bb to your computer and use it in GitHub Desktop.
Unity 2017.4.27 splash screen storyboard twist
# ProjectSettings:
set LaunchScreen.storyboard as splash screen storyboard in project settings
# Assets:
- put CustomSplashViewController.mm in Assets/Plugins/iOS/
- put CustomSplashViewController.h in Assets/Plugins/iOS/
# ios postprocess:
- set UILaunchStoryboardName to 'ActualLaunchScreen' in xcode project's info.plist
- copy LaunchScreen-Default.png to xcode project root
- copy ActualLaunchScreen.storyboard to xcode project root
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="15705" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="Bqq-lu-R9T">
<device id="retina6_1" orientation="landscape" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="15706"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="NjY-pa-eES">
<objects>
<viewController id="Bqq-lu-R9T" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="omG-WO-XaD">
<rect key="frame" x="0.0" y="0.0" width="896" height="414"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="LaunchScreen-Default.png" translatesAutoresizingMaskIntoConstraints="NO" id="NTg-Sj-gK7">
<rect key="frame" x="0.0" y="0.0" width="896" height="414"/>
</imageView>
</subviews>
<color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
<constraints>
<constraint firstAttribute="trailing" secondItem="NTg-Sj-gK7" secondAttribute="trailing" id="gRm-Bp-e2m"/>
<constraint firstAttribute="bottom" secondItem="NTg-Sj-gK7" secondAttribute="bottom" id="isP-OG-yAi"/>
<constraint firstItem="NTg-Sj-gK7" firstAttribute="leading" secondItem="omG-WO-XaD" secondAttribute="leading" id="lZq-2E-iEu"/>
<constraint firstItem="NTg-Sj-gK7" firstAttribute="top" secondItem="xkV-D4-5CV" secondAttribute="top" id="wUv-Xi-3vm"/>
</constraints>
<viewLayoutGuide key="safeArea" id="xkV-D4-5CV"/>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="nab-O5-gdx" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="205.58035714285714" y="37.681159420289859"/>
</scene>
</scenes>
<resources>
<image name="LaunchScreen-Default.png" width="1218" height="562.5"/>
</resources>
</document>
#ifndef CustomSplashViewController_h
#define CustomSplashViewController_h
@interface CustomSplashViewController: UIViewController
- (UIInterfaceOrientationMask)supportedInterfaceOrientations;
@end
#endif /* CustomSplashViewController_h */
#import <Foundation/Foundation.h>
#import "CustomSplashViewController.h"
@implementation CustomSplashViewController
- (UIInterfaceOrientationMask)supportedInterfaceOrientations
{
UIInterfaceOrientationMask ret = 0;
ret |= (1 << UIInterfaceOrientationLandscapeRight);
ret |= (1 << UIInterfaceOrientationLandscapeLeft);
return ret;
}
@end
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="15505" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="Bqq-lu-R9T">
<device id="retina6_1" orientation="landscape" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="15509"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--Custom Splash View Controller-->
<scene sceneID="NjY-pa-eES">
<objects>
<viewController modalPresentationStyle="fullScreen" id="Bqq-lu-R9T" customClass="CustomSplashViewController" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="omG-WO-XaD">
<rect key="frame" x="0.0" y="0.0" width="896" height="414"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="LaunchScreen-Default.png" translatesAutoresizingMaskIntoConstraints="NO" id="NTg-Sj-gK7">
<rect key="frame" x="0.0" y="0.0" width="896" height="414"/>
</imageView>
</subviews>
<color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
<constraints>
<constraint firstAttribute="trailing" secondItem="NTg-Sj-gK7" secondAttribute="trailing" id="gRm-Bp-e2m"/>
<constraint firstAttribute="bottom" secondItem="NTg-Sj-gK7" secondAttribute="bottom" id="isP-OG-yAi"/>
<constraint firstItem="NTg-Sj-gK7" firstAttribute="leading" secondItem="omG-WO-XaD" secondAttribute="leading" id="lZq-2E-iEu"/>
<constraint firstItem="NTg-Sj-gK7" firstAttribute="top" secondItem="xkV-D4-5CV" secondAttribute="top" id="wUv-Xi-3vm"/>
</constraints>
<viewLayoutGuide key="safeArea" id="xkV-D4-5CV"/>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="nab-O5-gdx" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="205.58035714285714" y="37.681159420289859"/>
</scene>
</scenes>
<resources>
<image name="LaunchScreen-Default.png" width="1218" height="562.5"/>
</resources>
</document>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment