GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - Jinya/SwiftUI_HomeIndicatorAutoHiddenDemo: A demo for hiding iOS system home indicator when our app written by SwiftUI.

BranchesTags
Open more actions menu

Latest commit

 

History

2 Commits
2 Commits

Folders and files

NameName
Last commit message
Last commit date
HideHomeIndicatorDemo.xcodeproj
HideHomeIndicatorDemo.xcodeproj
 
 
HideHomeIndicatorDemo
HideHomeIndicatorDemo
 
 
.DS_Store
.DS_Store
 
 
README.md
README.md
 
 

Repository files navigation

HomeIndicator AutoHidden Demo for SwiftUI

A demo for hiding iOS system home indicator when our app written by SwiftUI.

Known Issues

Currently(SwiftUI 3, Swift5.5, iOS 15), the SwiftUI framework doesn't provide a viewModifier of View for us to set a property like prefersHomeIndicatorAutoHidden in UIKit's UIViewController to make home indicator auto hidden.

Solution

Assign the SwiftUI View to a UIHostingController instance's rootView

struct SwiftUIView: View {
    var body: some View {
        Text("SwfitUI view without the annoying home indicator!")
            .edgesIgnoringSafeArea(.all)
    }
}

class ViewController: UIViewController {
    override var prefersHomeIndicatorAutoHidden: Bool { true }
    
    private let childView = UIHostingController(rootView: SwiftUIView())
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        addChild(childView)
        view.addSubview(childView.view)
        childView.didMove(toParent: self)
        childView.view.frame = view.bounds
    }
    
    override func viewDidLayoutSubviews() {
        super.viewDidLayoutSubviews()
        
        childView.view.frame = view.bounds
    }
}

Future in SwiftUI 4

A viewModifier like edgesIgnoringSafeArea(.all) should be provide to View in SwiftUI.

About

A demo for hiding iOS system home indicator when our app written by SwiftUI.

Topics

homeindicatorhomeindicatorautohiddenswiftswiftuiuihostingcontrolleruiviewcontrollerrepresentableuiviewrepresentable

Resources

Readme
Activity

Stars

0 stars

Watchers

1 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.