Hosting UIKit in SwiftUI – Working with views, controllers, layers, coordinate systems, safe areas

We explore how to use UIKit views and layers in SwiftUI. This is for example useful to understand for the development of apps such as object detectors which show both the camera output and bounding boxes in the same view.

We see that the hosted view takes up all available space by default, while child views have dimension 0x0. Then, we learn that UIViews wrap Core Animation layers which are used for rendering in iOS apps. Afterwards, we explore how to work with a view’s two coordinate systems to position them, and that the logical coordinate system uses points instead of pixels. And finally, we learn about the safe areas of some iPhone models and how they influence the views.

00:00 Introduction
01:10 MVC design pattern
01:57 Hosting UIViewController
04:12 UIViews
06:03 CALayers
08:26 Coordinate systems
11:11 Safe areas
11:46 Conclusion


UIKit dev:
Core Animation:
Drawing in iOS:

Leave a Reply

Your email address will not be published.