设置LaunchScreen.storyboard竖屏显示

有时候我们希望App启动页竖屏显示,其它页面既可以竖屏又可以横屏,而在使用LaunchScreen.storyboard作为启动页时,由于LaunchScreen.storyboard无法使用自定义的ViewController,所以也没办法覆盖supportedInterfaceOrientations属性来修改启动页支持的界面方向,这个时候我们可以将Info.plist设置为仅竖屏显示,然后在AppDelegate中设置为支持横竖屏。

    func application(_ application: UIApplication, supportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMask {
        return .allButUpsideDown
    }

下面是苹果对该方法的说明,意思是如果未实现此方法,则使用Info.plist里key为supported interface orientations的值作为App支持的界面方向,否则使用该方法返回值作为App支持的界面方向。

- (UIInterfaceOrientationMask)application:(UIApplication *)application
supportedInterfaceOrientationsForWindow:(UIWindow *)window;
This method returns the total set of interface orientations supported by the app. When determining whether to rotate a particular view controller, the orientations returned by this method are intersected with the orientations supported by the root view controller or topmost presented view controller. The app and view controller must agree before the rotation is allowed.
If you do not implement this method, the app uses the values in the UIInterfaceOrientation key of the app’s Info.plist as the default interface orientations.

在Xcode中制作LaunchScreen.storyboard可以通过以下步骤进行: 1. 打开Xcode并创建一个新的项目或打开现有的项目。 2. 在项目导航栏中,找到并选中名为LaunchScreen.storyboard的文件。 3. 在Interface Builder中,你将看到一个可视化的画布,用于创建你的Launch Screen界面。 4. 你可以在右侧的对象库中选择和拖拽各种视图元素到画布上,比如标签、图像视图、按钮等等。根据你的需求,自定义你的Launch Screen界面。 5. 使用自动布局和约束来确保你的Launch Screen在各种设备和屏幕尺寸下都能正确显示。你可以使用Auto Layout来指定视图之间的关系和位置,以及对内容进行自适应布局。 6. 添加所需的背景图像或启动图像。你可以在图像资源选项卡中,将你的图像文件拖拽到LaunchScreen.storyboard上,并将其设置为背景图像或者其他所需的位置。 7. 根据需要,你可以使用动画效果或过渡效果来提高Launch Screen的可视化效果。这可以通过在Launch Screen上添加动画视图或切换视图的方式来实现。 8. 在你完成Launch Screen的设计和布局后,你可以选择在应用程序设置中将其设置为你的项目的主要启动界面。进入“General”选项卡,找到“App Icons and Launch Images”部分,选择“Launch Screen File”并选择你的Launch Screen.storyboard文件。 通过以上步骤,你可以使用Xcode中的Interface Builder创建和设计Launch Screen.storyboard,以实现你想要的启动界面效果。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值