xgqfrms™, xgqfrms® : xgqfrms's offical website of cnblogs! xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!

How to make iOS App fullscreen using SwiftUI views?

How to make iOS App fullscreen using SwiftUI views?

如何使用 SwiftUI 视图让 iOS App 全屏显示?

iPad 全屏时钟

自开发 App,无广告,纯净版 🚀

...todo

SwiftUI x fullscreen API

fullScreenCover

nonisolated
func fullScreenCover<Content>(
    isPresented: Binding<Bool>,
    onDismiss: (() -> Void)? = nil,
    @ViewBuilder content: @escaping () -> Content
) -> some View where Content : View

https://developer.apple.com/documentation/swiftui/view/fullscreencover(ispresented:ondismiss:content:)

nonisolated
func fullScreenCover<Item, Content>(
    item: Binding<Item?>,
    onDismiss: (() -> Void)? = nil,
    @ViewBuilder content: @escaping (Item) -> Content
) -> some View where Item : Identifiable, Content : View

https://developer.apple.com/documentation/swiftui/view/fullscreencover(item:ondismiss:content:)

import SwiftUI


struct FullScreenModalView: View {
  @Environment(\.presentationMode) var presentationMode
  var body: some View {
    VStack {
      Text("Hello, World!")
        .padding()
      Button("Dismiss") {
        presentationMode.wrappedValue.dismiss()
      }
    }
    .frame(maxWidth: .infinity, maxHeight: .infinity)
    .background(Color.red)
    .edgesIgnoringSafeArea(.all)
    .onTapGesture {
      presentationMode.wrappedValue.dismiss()
    }
  }
}



struct ContentView: View {
  @State private var isPresented = false
  var body: some View {
    Button("Show Full Screen Modal") {
      self.isPresented.toggle()
      // isPresented.toggle()
    }
    .fullScreenCover(isPresented: $isPresented, content: FullScreenModalView.init)
  }
}

struct ContentView_Previews: PreviewProvider {
  static var previews: some View {
    ContentView()
  }
}

@main
struct MyApp: App {
  var body: some Scene {
    WindowGroup {
      ContentView()
    }
  }
}

https://www.youtube.com/results?search_query=SwiftUI+Fullscreen

demos

fliqlo / 飞客

收费: $ 0.99 / ¥ 8.0

https://apps.apple.com/cn/app/fliqlo/id900833042?l=en-GB

image

image

https://search.bilibili.com/all?vt=61108718&keyword=ipad+桌面时钟

Web 网页版 WKWebView

Fullscreen API

webView.configuration.preferences.isElementFullscreenEnabled = true


webView.loadHTMLString("""
<script>
  button.addEventListener('click', () => {
    canvas.webkitRequestFullscreen()
  }, false);
</script>
…
""", baseURL:nil)


// 👇🏻 use this if you want to customize the full screen transactions in your app
let observation = webView.observe(\.fullscreenState, options: [.new]) { object, change in
  print("fullscreenState: \(object.fullscreenState)")
}

https://wwdcnotes.com/documentation/wwdcnotes/wwdc22-10049-whats-new-in-wkwebview/

refs



©xgqfrms 2012-2021

www.cnblogs.com/xgqfrms 发布文章使用:只允许注册用户才可以访问!

原创文章,版权所有©️xgqfrms, 禁止转载 🈲️,侵权必究⚠️!


posted @   xgqfrms  阅读(11)  评论(3编辑  收藏  举报
相关博文:
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· DeepSeek 开源周回顾「GitHub 热点速览」
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
历史上的今天:
2023-12-27 macOS Sonoma All In One
2022-12-27 Linux bash shell "${1}" All In One
2021-12-27 Linux Command Line Cheat Sheet All In One
2021-12-27 js array auto expand All In One
2020-12-27 上海市居住证积分办理流程 2020~2021 最新
2020-12-27 前端水印方案 All In One
2020-12-27 postman skills
点击右上角即可分享
微信分享提示