【问题标题】:How can we add a launch screen to a watch app?我们如何向手表应用程序添加启动屏幕?
【发布时间】:2021-09-09 06:12:55
【问题描述】:

我正在使用 SwiftUI 创建一个 watchOS 应用程序,我希望添加一个启动画面,但我不确定这是否可能。我已将以下内容添加到 Info.plist 文件中,但似乎没有显示启动画面。

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>UILaunchScreen</key>
    <dict>
        <key>UIImageName</key>
        <string>Rupee</string>
    </dict>
    <key>CFBundleDevelopmentRegion</key>
    <string>$(DEVELOPMENT_LANGUAGE)</string>
    <key>CFBundleDisplayName</key>
    <string>Sample</string>
    <key>CFBundleExecutable</key>
    <string>$(EXECUTABLE_NAME)</string>
    <key>CFBundleIdentifier</key>
    <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
    <key>CFBundleInfoDictionaryVersion</key>
    <string>6.0</string>
    <key>CFBundleName</key>
    <string>$(PRODUCT_NAME)</string>
    <key>CFBundlePackageType</key>
    <string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
    <key>CFBundleShortVersionString</key>
    <string>1.0</string>
    <key>CFBundleVersion</key>
    <string>1</string>
    <key>CLKComplicationPrincipalClass</key>
    <string>$(PRODUCT_MODULE_NAME).ComplicationController</string>
    <key>NSAppTransportSecurity</key>
    <dict>
        <key>NSExceptionDomains</key>
        <dict>
            <key>google.com</key>
            <dict>
                <key>NSExceptionAllowsInsecureHTTPLoads</key>
                <true/>
                <key>NSIncludesSubdomains</key>
                <true/>
            </dict>
        </dict>
    </dict>
    <key>NSExtension</key>
    <dict>
        <key>NSExtensionAttributes</key>
        <dict>
            <key>WKAppBundleIdentifier</key>
            <string>Sample</string>
        </dict>
        <key>NSExtensionPointIdentifier</key>
        <string>Sample</string>
    </dict>
    <key>WKWatchOnly</key>
    <true/>
</dict>
</plist>

【问题讨论】:

标签: swiftui watchos


【解决方案1】:

很遗憾(截至 2021 年 9 月),WatchOS 尚不支持启动屏幕。我不知道你是否注意到了,但是当应用程序在手表上启动时,应用程序图标会显示在其周围有一个进度视图,这是应用程序的默认 WatchOS 启动屏幕并且无法更改。

欲了解更多信息:Could we set Launch screen in apple watch?

【讨论】:

  • 哦,是的,我注意到了一次。所以这意味着它仍然没有解决。 :(
  • 是的。为了帮助将来可能有这个问题的其他用户。如果它回答了您的问题,请您标记upvote并将其标记为答案。
【解决方案2】:

对于虚假的启动屏幕,您可以执行以下操作:

@State var shouldShowLaunchImage = true

var body: some View {
    ContentView()
        .overlay(
            Image("launch-image")
                .opacity(shouldShowLaunchImage ? 1 : 0)
        )
        .onAppear {
            DispatchQueue.main.asyncAfter(deadline: .now() + 3) {
                self.shouldShowLaunchImage = false
            }
        }
}    

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-04-27
    • 2013-06-25
    • 1970-01-01
    • 2017-10-27
    • 1970-01-01
    相关资源
    最近更新 更多