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 - BarbaraBeatrice/SwiftUI-in-UIKit: Example of integration of SwiftUI in UIKit

BranchesTags
Open more actions menu

Latest commit

 

History

11 Commits
11 Commits

Folders and files

NameName
Last commit message
Last commit date
SwiftUI in UIKit
SwiftUI in UIKit
 
 
.gitignore
.gitignore
 
 
README.md
README.md
 
 

Repository files navigation

SwiftUI in UIKit

This is a simple project that shows how you can integrate a SwiftUIView into an existing UIKit project.
You can find my full article about the integration of both frameworks here.

gif appù

Table of Contents

  • General Info
  • Technologies Used
  • Embed a SwiftUI view in UIKit
  • Contact

General Information

I started this project in order to understand how SwiftUI and UIKit can be integrated together to get the best out of both of them. I made an animation with SwiftUI and then I embedded it into a UIKit project. This is actually just one of two projects that I worked on, you can find the "UIKit in SwiftUI" part here.

Technologies Used

  • macOS - 12.1
  • Xcode - 13.3

Embed a SwiftUI view in UIKit

First of all, create a SwiftUI view inside the project (I created a simple custom loading animation).

gif animazione

In order to bind it with the existing project, you'll need to place it inside a ContainerView, which you can add to the storyboard from the library. image

You may have noticed that along with the ContainerView, a ViewController has also popped up, which in this case we'll remove because it needs to be replaced with the UIHostingController. image

To do this, add a UIHostingController from the library, then connect the ContainerView to it with control-drag and then select "embed" from the menu that opens. image image

Now open the assistant and, first of all, import SwiftUI into the ViewController. image

Then control-drag the segue you just created in the view controller and give it a name. image

Use auto-completion to help you and lastly enter the name of your SwiftUIView as the root view. image

Contact

Created by Barbara Beatrice

About

Example of integration of SwiftUI in UIKit

Topics

animationswiftswiftuiuihostingcontrolleruikit

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.